I am using asp.net 4.5 and latest MVC version. I need retrive deviceId
and body
from header when posting the form in the html page. At line public void Post([FromBody]string value)
value it is always null.
Wha am I doing wrong here?
namespace WebApi.Controllers
{
public class NotificationController : ApiController
{
// GET api/notification
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/notification/5
public string Get(int id)
{
return "value";
}
// POST api/notification
public void Post([FromBody]string value)
{
// value it is always null
}
// PUT api/notification/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/notification/5
public void Delete(int id)
{
}
}
}
<form action="/api/notification" method="post">
DeviceId: <input name="deviceId" value="gateeMachine">
Body: <input name="body" value="Warning Out of Paper">
<button>Tes send</button>
</form>