I have POST method like this
public void PostMethod([FromBody]string param)
{
var test = param;
}
And simple JS script
<script type="text/javascript">
$.ajax({
url: 'http://localhost:8101/sd/Localization/PostMethod',
type: 'POST',
data: {
param: 'test'
}
});
</script>
Ot work great. Ajax call is invoking the method BUT the param is null :/ always. I don`t know why. I can’t get it running. Can someone pls help me and show me the correct direction ?
// update
too check something i`ve created new project to be sure that i didn’t break something. Even in new project in default config I always get null
Because
paramis a simple type, so to make it work for simple type, you just:If you still want to make POST request like yours, define you own strong type model:
So your action:
Or use
JObject:More information:
http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-1