Example of Configuration for lt;httpErrorsgt;(lt;httpErrorsgt; 的配置示例)
问题描述
我有一个在 IIS 7 上本地运行的 Asp.Net 4 中的 Web 应用程序.我需要显示一个自定义页面 (404) 和一个 500 来代替 IIS 的默认页面.在 Web.Config 中使用这个 httpErrors
I have a Web Application in Asp.Net 4 running locally on IIS 7. I need display a Custom Page (404) and an 500 instead for the defaults page for IIS. Using this httpErrors in Web.Config
<system.webServer>
<httpErrors>
我的网站在
C:inetpubwwwrootmysite
我的自定义错误页面位于:
My Custom Error page in:
C:inetpubwwwrootmysiteErrorPages404.htm
C:inetpubwwwrootmysiteErrorPages505.htm
我不明白它是如何工作的.能否请您提供一个代码示例?
I do not understand how it works. COuld you please provide me a sample of code?
谢谢
推荐答案
我用这个解决了我的问题.
I solved my problem with this.
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode='-1' />
<remove statusCode="500" subStatusCode='-1' />
<error statusCode="404" path="/404.aspx" prefixLanguageFilePath="" responseMode="ExecuteURL" />
<error statusCode="500" path="/500.aspx" prefixLanguageFilePath="" responseMode="ExecuteURL" />
</httpErrors>
这需要进入 Web.config
,在 <configuration>
> <system.webServer>
This needs to go in Web.config
, under <configuration>
> <system.webServer>
例如
<configuration>
<system.webServer>
<httpErrors ...>
// define errors in here ...
</httpErrors>
</system.webServer>
</configuration>
这篇关于<httpErrors> 的配置示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:<httpErrors> 的配置示例


- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- WebMatrix WebSecurity PasswordSalt 2022-01-01