views:

39

answers:

2

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 does not. How can I know the reason to this?

+2  A: 

Try giving your Method the following attribute:

[AcceptVerbs(HttpVerbs.Post)]
Falle1234
Already tried that but it does not work, also as far as I know, both get and post are accepted when none is specified.
Serhat Özgel
A: 

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.

tvanfosson
I already checked the url by firebug. It is correct, and when I copy paste it and make the exact request with GET, the method runs.
Serhat Özgel