2

I have an application running on Sitecore 7.5 where my code is invoking an MVC Action at client side. The action method is decorated with the [HttpPost] attribute.

https://www.XYZ.com/api/sitecore/TestController/PostTestAction

As per the John West's post (https://www.sitecore.net/company/blog/386/the-mystery-of-the-sitecoreactioninvoker-3355_, an HTTP request for an action that does not exist results in exception details in the response such as the following:

8704 08:36:00 ERROR Application error. Exception: System.InvalidOperationException Message: Could not invoke action method: PostTestAction. Controller name: TestController. Controller type: XYZ.TestController Source: Sitecore.Mvc at Sitecore.Mvc.Controllers.SitecoreActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.<>c__DisplayClass22.b__1e() at System.Web.Mvc.Async.AsyncResultWrapper.<.cctor>b__0(IAsyncResult asyncResult, Action action) at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at Sitecore.Mvc.Routing.RouteHttpHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

In my case, however this error is intermittent. As the website is always available, it is highly unlikely that the API endpoints are not accessible. This action definitely exists and does what its supposed to do more often than not for the end users. Only the intermittent failures responds with the ASP.NET 404 page not found to the end user.

I have been checking the server logs but couldn't figure out a reason why this action shall execute one time and not another. The windows server logs doesn't show any sporadic network failure or latency at all.

Only thing I can relate to is the post: (https://stackoverflow.com/questions/38761739/sitecore-ajax-post-could-not-invoke-action-method) Again it seems highly unlikely but seems like SitecoreActionInvoker randomly misses executing the 'POST' action.

Appreciate the troubleshooting tips here.

8
  • Is it happening only on CD? Do you use load balancer with more CD instances? Just because as far as I know the /api/sitecore route should not be available on CD instances because it is for CM. Jan 18 '18 at 7:27
  • Arvind, yes we do use load balance with 4 CD instances. However I believe this /api/sitecore has nothing to do with the sitecore shell. Its just the way Sitecore MVC actions are called from the client scripts without specifying the routes in the routing table.
    – Abhi
    Jan 18 '18 at 14:16
  • Could you please check this, I think you have the same issue: sitecore.stackexchange.com/questions/6109/…. If yes, you can mark your question as duplication. Jan 18 '18 at 15:14
  • Maybe from the 4 CD instances few of them has the speak config enabled and others not that's why it does not happen all the time. Jan 18 '18 at 15:20
  • Tamas, I just checked with the devops team. Yes its enabled on all the 4 production CD instances.
    – Abhi
    Jan 18 '18 at 17:32
0

Closing this thread now. I was able to reproduce this issue on the CD servers. Basically its more related to the user behavior than Sitecore functionality itself. I posted a separate thread question for that particular user behavior where user manually submits a sitecore ajax post url to the browser causing invalid Sitecore item fetch.

Restricting user from forcing manual submit to the Sitecore Url

Not the answer you're looking for? Browse other questions tagged or ask your own question.