如何使用 IIS 7 集成管道让自定义错误页适用于经典 ASP
我正在开发一个具有旧版经典 ASP 页面(根据需要转换为 ASP.NET)和新 ASP.NET 页面的网站。使用 IIS 7 Integrated Pipeline 对我们的配置非常有帮助。例如,我们只需配置 web.config 文件的相应部分,就可以使表单身份验证自动与经典 ASP 页面一起工作(即无需对经典 ASP 页面进行任何更改,有关详细信息,请参阅 这个)。
我的一位同事认为 web.config
对于在 IIS7 下运行且具有集成管道的网站,是否可以根据 web.config 将自定义错误页面应用到经典 ASP 页面?如果是这样,怎么办?
I'm working on a website with legacy Classic ASP pages (being converted to ASP.NET on an as needed basis) and new ASP.NET pages. Use of IIS 7 Integrated Pipeline has been very helpful with our configuration. For example, we were able to get forms authentication working auto-magically with the classic ASP pages simply by configuring the appropriate sections of the web.config file (i.e. no changes were required to the Classic ASP pages, for more info see this).
A colleague of mine believes that custom error pages, as specified in the web.config <customErrors> section, should also be auto-magically applied to the classic ASP pages, but for our website it only works for the ASP.NET pages. Nor have I been able to find any information describing the capability of applying custom error pages to Classic ASP with the IIS 7 integrated pipeline.
Is it possible to apply custom error pages to Classic ASP pages per a web.config for an website running under IIS7 with integrated pipeline? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IIS7 自定义错误页面在
配置部分中处理,而不是在
下的
部分中处理。 code> 仅适用于 ASP.NET:请注意这些设置与 ASP.NET 自定义错误相冲突。如果您运行的是 .NET 3.5 及更高版本,则可以设置
Response.TrySkipIisCustomErrors
在 ASP.NET 错误页面代码隐藏(或错误控制器,如果使用 MVC)中,以防止 IIS 覆盖您的 ASP.NET 错误页面(s):Rick Strahl 的这篇文章更深入地解释了这个问题:
The IIS7 custom error pages are handled in the
<system.webServer>
configuration section not the<customErrors>
section under<system.web>
which applies to ASP.NET only:Beware though of these settings conflicting with ASP.NET custom errors. If you're running .NET 3.5 and above you can set
Response.TrySkipIisCustomErrors
in your ASP.NET error page code-behind (or error controller if using MVC) to prevent IIS overriding your ASP.NET error page(s):This article by Rick Strahl explains this problem in a bit more depth: