在ASP.Net网站上实现自定义错误页面 [英] Implementing a Custom Error page on an ASP.Net website
本文介绍了在ASP.Net网站上实现自定义错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ASP.Net网站,并且我想使用自定义错误页面。我将以下代码放入web.config
I have an ASP.Net website and I want to use a custom error page. I put the following code in my web.config
<customErrors mode="On" defaultRedirect="~/error.aspx">
<error statusCode="404" redirect="~/error.aspx" />
</customErrors>
问题是当我转到不存在的URL时仍使用指定的404错误页面在IIS管理器中。
The problem is when i go to a URL that does not exist is still uses the 404 error page specified in IIS Manager.
问题:如何使用我创建的error.aspx页面?为什么IIS管理器中的设置会覆盖web.config?
Question: How can I make it use the error.aspx page I have created? Why do the settings in IIS Manager override the web.config?
推荐答案
尝试这种方式,几乎是一样的..但这就是我的意思
Try this way, almost same.. but that's what I did, and working.
<configuration>
<system.web>
<customErrors mode="On" defaultRedirect="apperror.aspx">
<error statusCode="404" redirect="404.aspx" />
<error statusCode="500" redirect="500.aspx" />
</customErrors>
</system.web>
</configuration>
或尝试从IIS设置更改404错误页面(如果紧急需要)。
or try to change the 404 error page from IIS settings, if required urgently.
这篇关于在ASP.Net网站上实现自定义错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文