Search code examples
c#asp.net-mvctestinghttp-postfiddler

Set test information in body of POST request for .NET Request.Form


I'm not entirely sure how to word the title for the best. But I know I've done this before and can't seem to find out how to do this.

I have a method like this

[HttpPost]
public string doSomething()
{
   string formValue = Request.Form["MyKey"];
   return formValue;
}

Then I send up a fiddler POST sample request.

I put something like this in the Request body

MyKey=SomeValue

However, when I invoke fiddler I get a null formValue string.

I know i've done this before, I just can't seem to remember how to pass this information in the body of the request.


Solution

  • As requested, here's my comment in the form of an answer:


    Possibly you forgot to set the content-type to application/x-www-form-urlencoded?

    This is necessary in order for the body to be understood to be containing form data.