Global_Asax Application_Error 被触发,而不是默认的 IIS7 404 页面未找到页面
我有一个具有 Global_Asax 和自定义错误页面的 Web 应用程序。当用户尝试进入不存在的无效页面时,Global_asax 中会触发 Application_Error 并记录异常,但这并不是真正的异常(您可以在下面查看异常详细信息)。我不想在 global_asax 中处理这种情况,而是在 IIS 中处理。我还尝试输入以 .asp 和 .html 结尾的无效路径,它们工作正常(它们不是以 global_asax 结尾,而是以默认 404 页面结尾)。
我需要知道必须从 IIS7 管理器更改哪些设置。
任何帮助将不胜感激。
错误 - 文件“/restricted/ff.aspx” 不存在。
System.Web.HttpException:文件 “test.aspx”不存在。在 System.Web.UI.Util.CheckVirtualFileExists(虚拟路径 虚拟路径)位于 System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(虚拟路径 virtualPath,布尔值 noBuild,布尔值 允许跨应用程序,布尔值 允许BuildInPrecompile)在 System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext 上下文,虚拟路径虚拟路径, 布尔值 noBuild, 布尔值 允许跨应用程序,布尔值 允许BuildInPrecompile)在 System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath、HttpContext 上下文、 布尔值allowCrossApp,布尔值 无断言)在 System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath,类型需要BaseType, HttpContext 上下文,布尔值 allowCrossApp,布尔值 noAssert) at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext 上下文,字符串请求类型, 虚拟路径 虚拟路径,字符串 物理路径)在 System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,布尔值&同步完成)
I have a Web Application which has Global_Asax and a Custom Error Page. When user tries to enter to an invalid page which doesn't exist, Application_Error is fired in Global_asax and exception is logged which isn't really an exception (You can see the exception details below). I don't want to handle this case in global_asax but rather in IIS. I've also tried to enter invalid paths ending with .asp and .html and they work fine(They don't end in global_asax but rather in default 404 page).
I need to know which setting I have to change from IIS7 Manager.
Any help would be appreciated.
Error - The file '/restricted/ff.aspx'
does not exist.System.Web.HttpException: 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) at
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext
context, VirtualPath virtualPath,
Boolean noBuild, Boolean
allowCrossApp, Boolean
allowBuildInPrecompile) at
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath
virtualPath, HttpContext context,
Boolean allowCrossApp, Boolean
noAssert) at
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType,
HttpContext context, Boolean
allowCrossApp, Boolean noAssert) 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.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试以下其中一项:
编辑web.config文件以查找自定义错误:
添加
404.aspx
页面并将状态代码设置为 404:如果这对您没有帮助,也可以尝试此操作(可能会由您的母版页重置):
You can try one of these:
Edit the web.config file for custom errors:
Add a
404.aspx
page and set the status code to 404:If it doesn't help you try this as well (it might be reset by your masterpage):