<httpErrors> 的配置示例 [英] Example of Configuration for <httpErrors>

查看:26
本文介绍了<httpErrors> 的配置示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 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>

这篇关于&lt;httpErrors&gt; 的配置示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆