ASP.NET MVC 6(DNX 4.5.1).
In my PUT method.
public class MyController : ApiController
{
.......
// UPDATE
[Microsoft.AspNet.Mvc.HttpPut]
public void Update()
{
try
{
var item = new Item()
{
UserName = Request.Form["UserName"]
};
_itemRespository.Update(item);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
}
What I got:
Error CS1061 'HttpRequestMessage' does not contain a definition for 'Form' and no extension method 'Form' accepting a first argument of type 'HttpRequestMessage' could be found (are you missing a using directive or an assembly reference?) MyProject.DNX 4.5.1
There is a similar question, but I don't see help me.
EDIT:
The link uses POST
to pass the data to the method. He passed string value
in the method. In another word, he knows the value in advance. Well, in my case I use jqgrid to edit my data. After I click the submit button, I think that the edited data is from the Request Form
. I don't know it yet in advance.