Just a quick ASP.NET Web API tip today…
If you want to access the form data posted to a an ASP.NET Web API controller, the easiest solution is to use the built-in FormUrlEncodedMediaTypeFormatter, which knows how to map every key/value in the form data to a FormDataCollection.
In your controller method, you can specify the FormDataCollection as a parameter:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebAPISampleController: ApiController | |
{ | |
public void Post(FormDataCollection form) | |
{ | |
} | |
} |