Freigeben über


ASP.NET MVC Intermittent exceptions public action method ‘abc’ could not be found

 

In one of our ASP.NET MVC applications, we have enabled email notification/DB logging on exceptions. When we promoted the application from Staging to Production, we started getting exceptions for our Logout action. The exception used to look like this:

Message: A public action method 'Logout' was not found on controller 'MyMvcApp.Web.Controllers.AccountController'.

Stack Trace:
at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.b__4()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.b__0()
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I searched all placed in my code but couldn’t find what is going wrong. Finally – got the help from following thread on Stackoverflow:

https://stackoverflow.com/questions/1745182/intermittent-asp-net-mvc-exception-a-public-action-method-abc-could-not-be-foun

I tried both web.config setting to deny verbs and removing the [HttpGet] attribute from the action – both works fine.