asp.net mvc does not run method when the request method is POST
I have a method in a controller:
public class WorkController : Controller
{
public JsonResult GetWorks()
{
...
return Json(outDto);
}
}
When I make a get request by Work/GetWorks, the method runs. When I do the same with a POST request, Application_BeginRequest runs, but the method 开发者_StackOverflow中文版does not. How can I know the reason to this?
Try giving your Method the following attribute:
[AcceptVerbs(HttpVerbs.Post)]
Can you show the code that generates the post action (i.e., BeginForm())? Is the view generating the form rendered from the same controller? My suspicion is that it may be mapped onto a different controller. You should check that the URL is what you expect.
精彩评论