c# - Accessing route and POST params in Web Api 2 Controller Method -


i have controller needs access both route , post body parameters. when use implementation

public class messagecontroller : apicontroller {     [route( "data/message/{apikey}/{userid}" )]      [httppost]     public message post( guid apikey, string userid, [frombody] string message)     {         // ...     } } 

the message argument null.

how can access apropos data?

[frombody] parameters must encoded value

don't try this:

public message post( guid apikey, string userid, [frombody] string message) {     // ... } 

try instead

 public message post( guid apikey, string userid, [frombody] string value)  {     // ...  } 

and use kind of code post request jquery:

  $.post('yourdomain/data/message/{apikey}/{userid}', { '': value }); 

for more detail, here link http://encosia.com/using-jquery-to-post-frombody-parameters-to-web-api/


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -