The file '/test.aspx' does not exist. CheckVirtualFileExists exception

0

When hosting a website in an Azure web app, I get the this error when trying to access a non existing aspx file.

I'm expecting to get a 404 response, but instead I get a 500 exception.

I request an other file type I get the expected 404 response.

When I run the same site on an IIS I get the expected 404 for the aspx file

Failed Request Trace: 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)
asp.net
azure
iis
azure-web-sites
asked on Stack Overflow Dec 6, 2018 by Rasmus • edited Dec 10, 2018 by huysmania

1 Answer

0

I'm expecting to get a 404 response, but instead I get a 500 exception.

The ASP.NET pipeline tries to find the handler for the request that ends with /test.aspx, which is actually the page itself, unless you've routed the request to some other URL.

If it can't find this handler, you get the error. It's not a 404 because the request didn't even get handled. So the actual status code returned is 500.

answered on Stack Overflow Dec 6, 2018 by Joey Cai

User contributions licensed under CC BY-SA 3.0