1

I'm seeing lots of the following error, which I think is down to HEAD requests to an action method (from bots perhaps):

A public action method 'index' was not found on controller     'MyWebsite.MyController'.
   at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
   at EPiServer.Web.Mvc.ActionControllerBase.HandleUnknownAction(String     actionName)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult     asyncResult, ExecuteCoreState innerState)
   at     System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyn    cResult asyncResult)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at     System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyn    cResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult     asyncResult, ProcessRequestState innerState)
   at     System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyn    cResult asyncResult)
   at     System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.I    ExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&     completedSynchronously)

My action method was originally only set up to accept GET requests, but I have now changed it to accept HEAD requests too e.g.:

    [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head)]
    public async override Task<ActionResult> Index()
    {
      ....
      return View(new Model());
    }

However, when I test a HEAD request for the page, I'm seeing the same error in the response and a 404 status code.

Anbody have any ideas what could be causing this please?

UPDATED to include Controller inheritance (removed quite a bit for simplicity):

MyController...

 public class MyController: BasicContentPageController<MyPageType>
{


    public MyController(IPageUrlProvider pageUrlProvider)
        : base(pageUrlProvider)
    {

    }

[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head)]
    public async override Task<ActionResult> Index()
    {
    ...
    return View(new Model());
    }

}

...inherits from BasicContentPageController...

 public abstract class BasicContentPageController<T> : MyBasePageContoller<T> where T : MyBasePageType
    {

 protected BasicContentPageController(IPageUrlProvider pageUrlProvider)
        : base(pageUrlProvider)
    {

    }

 [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head)]
    public virtual async Task<ActionResult> Index()
    {
        return View(await GetBasicPageViewModel());
    }

}

...inherits from MyBasePageController...

 public abstract class MyBasePageContoller<T> : PageController<T>
    where T : MyBasePageType
{
protected readonly IPageUrlProvider PageUrls;

 protected MyBasePageContoller(IPageUrlProvider pageUrlProvider)
    {
        PageUrls = pageUrlProvider;

    }

}
user806982
  • 135
  • 4
  • 16

0 Answers0