skip to Main Content

I have an iis site hosting multiple ASP.NET web apps. I’m seeing a sporadic issue where certain web apps are returning the following server error (shown in the front-end/browser and logged as a warning in the web server’s event viewer).

Exception type: InvalidOperationException 
    Exception message: Failed to map the path '/MyWebApp1/Scripts/App/Controllers/'.
   at System.Web.Configuration.ProcessHostConfigUtils.MapPathActual(String siteName, VirtualPath path)
   at System.Web.Configuration.ProcessHostServerConfig.System.Web.Configuration.IServerConfig.MapPath(IApplicationHost appHost, VirtualPath path)
   at System.Web.Hosting.MapPathBasedVirtualPathEnumerator..ctor(VirtualPath virtualPath, RequestedEntryType requestedEntryType)
   at System.Web.Hosting.MapPathBasedVirtualPathCollection.System.Collections.IEnumerable.GetEnumerator()
   at System.Linq.Enumerable.<CastIterator>d__97`1.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
   at System.Web.Optimization.BundleDirectoryItem.ProcessDirectory(BundleContext context, String directoryVirtualPath, VirtualDirectory dirInfo, List`1 files)
   at System.Web.Optimization.BundleDirectoryItem.AddFiles(List`1 files, BundleContext context)
   at System.Web.Optimization.Bundle.EnumerateFiles(BundleContext context)
   at System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context)
   at System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context)
   at System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath)
   at System.Web.Optimization.AssetManager.EliminateDuplicatesAndResolveUrls(IEnumerable`1 refs)
   at System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths)
   at ASP._Page_Views_Shared__Layout_cshtml.Execute() in C:WebsitesMySiteMyWebApp1ViewsShared_Layout.cshtml:line 21
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content)
   at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body)
   at System.Web.WebPages.WebPageBase.PopContext()
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   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.End(IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   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.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   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)

This initial request that fails is fetching the web content for the app. This app has its js bundled and minified. So it appears the code in the stack trace is extracting the individual js files from the bundle and attempting to map their virtual paths to actual, physical paths, but fails to do so.

The issue has happened twice now for 2 different web apps on the same site. But for other web apps under the same site, it hasn’t occurred. Once it occurred, the only way to clear it up was an application pool recycle and cache refresh.

  • I have not been able to reproduce the issue, and it seems sporadic.
  • There doesn’t seem to be anything different or unique about the folder permissions for the app pools of the apps that got the issue vs. those that didn’t.
  • I haven’t done anything to rename the site or change physical/virtual paths.

The existing threads I’ve seen on this error seem to suggest either permissions issues or directory naming mismatches, but the sporadic nature of this issue seems to suggest otherwise.

From looking at https://referencesource.microsoft.com/#System.Web/Configuration/ProcessHostConfigUtils.cs,3335ae12f0c53562,references, it seems like something is going wrong in MgdMapPathDirect from webengine4.dll. But I’m sure there is any way to log/capture what is occurring in this assembly.

Does anyone have any more ideas?

2

Answers


  1. This happens due to attempting to execute an action of a controller, but the controller or the action was not found. You surely have a timestamp of these warnings/errors (see https://stackify.com/beyond-iis-logs-find-failed-iis-asp-net-requests/) and you need to look into what requests were being sent to the server just before this (see https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms525410(v=vs.90)), identify what controller and action is being triggered when this happens, narrow down the set of possible culprits.

    This should help you identify what was the bad requests. It is not necessarily originating even inside the application where the warning manifests.

    The exception is likely thrown due to the removal/renaming of a controller or action that’s still being referred to as was before the change.

    Login or Signup to reply.
  2. Based on the stack trace provided, on _layouts.cshtml, the file is referencing an optimization bundle that includes the path "…/App/Controllers", i am assuming you have verified that the directory exists. i am thinking, the line 21 mentioned in the trace, is likely a Scripts.Render() or Styles.Render() which i think would be rendering from "~bundles/app", can you check to see in your BundleConfig.cs what’s that mapped too and if any *.js are in that "../Controllers" directory?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search