文件“ /test.aspx”不存在。 CheckVirtualFileExists异常

时间:2018-12-06 07:34:22

标签: asp.net azure iis azure-web-sites

在Azure Web应用程序中托管网站时,尝试访问不存在的 aspx 文件时出现此错误。

我希望得到404响应,但我却得到500异常。

我请求其他文件类型,得到了预期的404响应。

当我在IIS上运行相同的站点时,我会得到预期的404 aspx文件

失败的请求跟踪Link to Failed Request Trace

Stacktrace

System.Web.HttpException (0x80004005): The file '/test.aspx' does not exist. 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.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute(
 at System.Web.HttpApplication.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0(
 at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step
 at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

1 个答案:

答案 0 :(得分:0)

  

我希望得到404响应,但我却得到500异常。

ASP.NET管道会尝试查找以/test.aspx结尾的请求的处理程序,该请求实际上是页面本身,除非您已将请求路由到其他URL。

如果找不到此处理程序,则会出现错误。 这不是404,因为请求甚至都没有得到处理。所以返回的实际状态码是500。