开发者

MVC: A public method on my controller is called OK in my development server, but not the testing server

I am completely baffled by this. I have a public method开发者_C百科 on my controller which works on my development machine. But when I deploy the app I get an error message saying the method is not found;

    [HttpGet]
    [Authorize(Roles = "Administrator, AdminIT, ManagerIT")]
    public ActionResult ListExistingIT(GridSortOptions sort, int? page)
    {
        if (Request.QueryString["lastPersonMessage"] == null)
            ViewData["LastPersonMessage"] = string.Empty;
        else
            ViewData["LastPersonMessage"] = Request.QueryString["lastPersonMessage"];
        EmployeeListViewModel elvm = new EmployeeListViewModel();
        elvm.EmployeeList = EmployeeExtended.GetITEmployees();
        if (sort.Column != null)
        {
            elvm.EmployeeList = elvm.EmployeeList.OrderBy(sort.Column, sort.Direction);
        }
        elvm.EmployeeList = elvm.EmployeeList.AsPagination(page ?? 1, Utility.GetPageLength());
        ViewData["sort"] = sort;
        return View(elvm);
    }

The error message is; System.Web.HttpException: A public action method 'ListExistingIT' was not found on controller 'SHP.Controllers.EmployeeController'.

Now you might think that IIS is not picking up the latest deployment. However I make a change elsewhere and deploy it, and that works. I also restart IIS as well. I cannot imagine how this happens, or how to detect where the error could be.


There is plenty of discussion on a similar (the same?) issue here on SO:Intermittent asp.net mvc exception: “A public action method ABC could not be found on controller XYZ.”


I can think of 3 different possibilities:

  1. A conflict with the HttpVerb causing the method not to be found.
  2. A conflict with the filters applied causing the method to be avoided.
  3. A routing issue, but this one is probably the last possibility. You may want to try testing with the RouteDebugger and see what that shows you.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜