问题
I have this code:
return RedirectToAction("Save", "RequestFinishedDocument",
new {requestId = requestFinished.Request_ID, requestFinishedId = requestFinished.ID});
And in my controller I have:
public class RequestFinishedDocumentController : Controller
{
[HttpPost]
public JsonResult Save(int requestId, int requestFinishedId)
{
//todo
}
}
But on the RedirectToAction call I get the exception message: A public action method 'Save' was not found on controller 'SuiP.Controllers.RequestFinishedDocumentController'.
What's wrong?
Thank
回答1:
RedirectToAction
performs a HTTP GET. Your action method only accepts a HTTP POST.
回答2:
Try changing it to:
public class RequestFinishedDocumentController : Controller
{
[HttpGet]
public JsonResult Save(int requestId, int requestFinishedId)
{
//todo
}
}
and see if that works.
来源:https://stackoverflow.com/questions/6511786/why-action-not-found-in-my-controller