0

Occasionally when hitting a POST action method I'll get this exception:

Error Message:

(System.Web.HttpException): No matching action was found on controller 'xyz'. This can happen when a controller uses RouteAttribute for routing, but no action on that controller matches the request.

The action methods, as a rule, look like this:

[Authorize(Roles = "RoleOfSomeSort")]
[HttpPost]
[Route("path-1/path-2")]     
[ValidateAntiForgeryToken]
public ActionResult MethodName(ViewModel viewModel) 
{
    // Code
}

If I try again it will usually work. It's just an exception that pops up occasionally and then vanishes when I try to replicate it.

I'm testing the website in Azure Web Apps. I'm pretty sure I never got this error on my development machine. This error has happened in both Free and Shared mode.

Stack trace:

at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Let me know if you want any more information.

EDIT:

Request URLs that threw this exception:

/list/create-job-vacancy-listing

/list/create-services-labour-hire-listing

/my-stuff/my-listings/upload-photo

Digging into the ASP.NET MVC code here: https://github.com/ASP-NET-MVC/aspnetwebstack/blob/4e40cdef9c8a8226685f95ef03b746bc8322aa92/src/System.Web.Mvc/Controller.cs, here is the line that is failing (line 304):

protected virtual void HandleUnknownAction(string actionName)
    {
        // If this is a direct route we might not yet have an action name
        if (String.IsNullOrEmpty(actionName))
        {
            throw new HttpException(404, String.Format(CultureInfo.CurrentCulture,
                                       MvcResources.Controller_UnknownAction_NoActionName, GetType().FullName));
        }

So actionName is null or empty. Because of all the asynchronous stuff I'm not sure why this occasionally happens. Maybe it happens because of the asynchronicity? It's very rare but very annoying. Thanks.

nmit026
  • 3,024
  • 2
  • 27
  • 53
  • Without the request urls that cause the exception, it's pretty impossible to help you. – David L Aug 04 '16 at 03:00
  • Thanks @DavidL, I've added some. – nmit026 Aug 04 '16 at 03:08
  • @nmit026 Looks like you are doing HttpGet request and end point is HttpPost. But I'm confused why it works Occasionally or did you find what causes this error? In my case I was doing HttpGet to HttpPost end point and i received the exact same error. – S52 Feb 16 '18 at 17:02
  • @S52 That's not the reason. So am I. I'm not sure what this was, but I haven't seen it for quite a while. If it was something in the stack, maybe it disappeared because Microsoft fixed it. I don't know. – nmit026 Feb 17 '18 at 21:50

0 Answers0