在ASP.net自定义错误 [英] Custom errors in ASP.net
问题描述
我有一个网站,让我们假设它是
I have a website, lets assume it's
www.mydomain.com/a
我也有一个名为页
I also have a page named
list.aspx
我添加的配置设置到web.config文件自定义错误(主要是404500)。
I added configuration settings to the web.config file to customize the errors (mainly 404,500).
它完美,除了当请求不是一个页面,例如:
It works perfectly except for when the request is not a page, for example
www.mydomain.com/a/lEst.aspx //my custom page appears
www.mydomain.com/a/list //doesn't work (without aspx extension)
www.mydomain.com/B/aasd.aspx //doesn't work
在不工作的自定义错误,托管服务器会显示自己的自定义页面。
When the custom errors that don't work, the hosting server displays his own custom page.
我该如何解决这个问题?
How can I fix this?
推荐答案
的customErrors
将工作只有与ASP.Net扩展,因为它是由ASP.Net工作进程ahndled。如果你正在使用IIS7,用户 system.Webserver
部分。
customErrors
in system.web
will work only with ASP.Net extensions because it is ahndled by ASP.Net worker process. If you are using IIS7, user system.Webserver
section.
<httpErrors errorMode="Custom" existingResponse="Replace" >
<remove statusCode="404"/>
<error statusCode="404" path="/error404.aspx" responseMode="ExecuteURL"/>
</httpErrors>
这篇关于在ASP.net自定义错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!