仅在应用程序池回收后,MVC应用程序上的CheckVirtualFileExists异常

时间:2015-02-05 15:56:01

标签: asp.net-mvc exception iis

在使用大量使用的无故障ASP.NET MVC 3 Web应用程序上回收App Pool后访问任何URL(路由)时,我收到以下异常。

事实:

  • IIS 7
  • .NET 4.0经典模式应用程序池(仅池中的应用程序)
  • 通过HTTPS访问,作为其他应用程序的后端Web服务
  • 没有代码更改,网站正在进行常规的29小时自动更新 多年来在相同的代码上回收,现在是自动回收 禁用以保持网站上线
  • 应用程序池回收(或服务器重新启动)导致站点失败
  • 必须重新部署网站(从预编译版本中复制所有文件/文件夹 进入物理路径)以便在回收后再次使用
  • 我们正在捕获/记录Application_Error方法中的错误
  • 事件日志中没有未处理的异常
  • 任何访问任何路由/ URL的尝试都会生成异常

详细说明:

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

1 个答案:

答案 0 :(得分:1)

要调试CheckFileExists,您可能想要使用以下内容:

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!");