3

I get the following exception when accessing any URL (route) after a recycle of the App Pool on an otherwise trouble-free ASP.NET MVC 3 web application that is under heavy use.

The facts:

  • IIS 7
  • .NET 4.0 Classic Mode Application Pool (only application in the pool)
  • accessed via HTTPS as a back-end web-service by other applications
  • no code changes, site was undergoing regular 29 hour automatic recycles on the same code for years, automatic recycle is now disabled to keep the site up
  • App Pool recycle (or server restart) causes the site to fail
  • Must redeploy site (copy all files/folders from pre-compile build into physical path) to get it working again after a recycle
  • we are catching/logging the error in the Application_Error method
  • No unhandled exceptions in event log
  • Any attempt to access any route/URL generates the exception

Details:

HTTPErr Example: 2015-02-05 08:43:36 66.XXX.XXX.14 32224 10.XXX.XXX.185 443 HTTP/1.1 POST /IdentityToken/Endpoint.aspx - 6 Connection_Abandoned_By_ReqQueue MOBILEWEBSERVICE
Exception:
Timestamp: 2/5/2015 4:21:03 AM
Message: HandlingInstanceID: 438c9949-1ad2-49c4-9c7c-928bce03fd37
<Exception>
  <Description>An exception of type 'System.Web.HttpException' occurred and was caught.</Description>
  <DateTime>2015-02-05 04:21:03Z</DateTime>
  <ExceptionType>System.Web.HttpException, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</ExceptionType>
  <Message>The file '/Policies/Endpoint.aspx' does not exist.</Message>
  <Source>System.Web</Source>
  <HelpLink />
  <Property name="WebEventCode">0</Property>
  <Property name="ErrorCode">-2147467259</Property>
  <Property name="Data">System.Collections.ListDictionaryInternal</Property>
  <Property name="TargetSite">Void CheckVirtualFileExists(System.Web.VirtualPath)</Property>
  <Property name="HResult">-2147467259</Property>
  <StackTrace>   at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
   at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
   at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)</StackTrace>
  <additionalInfo>
    <info name="MachineName" value="SERVERNAME" />
    <info name="TimeStamp" value="2/5/2015 9:21:03 AM" />
    <info name="FullName" value="Legacy, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null" />
    <info name="AppDomainName" value="/LM/W3SVC/6/ROOT-1-130676015007079933" />
    <info name="ThreadIdentity" value="" />
    <info name="WindowsIdentity" value="IIS APPPOOL\MOBILEWEBSERVICE" />
  </additionalInfo>
</Exception>

enter image description here

Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70
Sean Anderson
  • 614
  • 8
  • 20
  • "I get the following exception" when you do *what*? – usr Feb 07 '15 at 11:34
  • "we are catching the error in our code and displaying a message" show that code. 2147467259 is access denied according to Google. – usr Feb 07 '15 at 11:34
  • I get the exception when accessing any of the URLs. The exception is being "caught" in that the Application_Error method is being called where we then log the exception--that is it. I did not find any helpful information searching google for that error code. – Sean Anderson Feb 08 '15 at 00:38
  • The way I understand this is that the application builds a route list when it starts, then each request is checked against this route list--part of which is a call to CheckVirtualFileExists and this is seemingly at the point where this fails. During the last maintenance window I cleared all of the .NET Temporary files for all of the .NET framework installations to make sure the site had a fresh recompile. – Sean Anderson Feb 08 '15 at 01:13
  • After flogging the google mercilessly I found this: http://stackoverflow.com/questions/22079387/mvc-routes-lost-after-app-pool-recycle-updated-title-3-3-14 – Sean Anderson Feb 08 '15 at 01:32
  • And did that solve your problem? – usr Feb 08 '15 at 08:39
  • Sorry, I should have elaborated. I am going to take a look at our build options and try making the site updateable to see if that solves the issue. It will take me some time to go through that testing though (I have to wait for a maintenance window). Even if it does solve the problem it does not explain exactly why this is happening. That I would love to know. – Sean Anderson Feb 08 '15 at 20:21
  • I have the same site published to a different app pool under a different virtual path on the same server and the same issue occurred. – Sean Anderson Feb 12 '15 at 16:28
  • retrieve the http status code that caused the exception, you can check for `HttpException.GetHttpCode()` – Amirhossein Mehrvarzi Feb 13 '15 at 07:52
  • Does `/Policies/Endpoint.aspx` exist? I hate to state the obvious, but you didn't mention whether you even checked. – NightOwl888 Feb 13 '15 at 12:40
  • Of course...as stated, it is a working site that stops working after a recycle. – Sean Anderson Feb 26 '15 at 19:26

1 Answers1

1

To debug CheckFileExists, you may wanna use something like this:

string fileName = "Test.aspx";
bool IsExistFile = System.IO.File.Exists(Server.MapPath("./") + fileName);

if (IsExistFile)
    Response.Write("Find the file!");
else Response.Write("The file is not exist!");
Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70