I've always known the customerrors error of setting up the Web. config (which is actually an XML file) to point to the URL of the custom error page, but today, when debugging, I find customerrors unable to jump to a custom page. I've been searching the internet for a while. HttpErrors can set a jump custom error page.
The Web. config file follows
<?XML version= "1.0"?><Configuration> <system.web> <compilationDebug= "true"targetframework= "4.5"/> <HttpRuntimetargetframework= "4.5"/> <customErrorsdefaultredirect= "errorpages\customerr.html"Mode= "On"> <ErrorStatusCode= "403"redirect= "errorpages\customerr403.html"/> <ErrorStatusCode= "404"redirect= "errorpages\customerr404.html"/> </customErrors> </system.web> <system.webserver> <httperrorsErrormode= "Custom"Defaultresponsemode= "File"> <ErrorStatusCode= "404"Substatuscode= "0"Path= "errorpages\httperr404.html"/> </httperrors> </system.webserver></Configuration>
Simply put, access static files such as. js,. html,. css,. jpg ... ) The error will be in accordance with the HttpErrors setting;
URLs that are inherited by the. NET handler (for example:. aspx,. ashx,. svc, MVC registered routes), and when an error occurs, the settings in the customerrors.
Http://localhost:2413/Default.aspx---> The correct URL
Http://localhost:2413/Default1111.aspx---> Controlled by customerrors
http://localhost:2413/Default.aspx1111---> Controlled by httperrors
Detailed explanations can be accessed from the links below
http://blog.csdn.net/a351945755/article/details/21003249
Http://blog.darkthread.net/post-2015-11-10-customerrors-and-httperrors.aspx
The original is as follows
Was quizzes the IIS Web site's custom HTTP 404 bug Web Set, learning to new things also to clarify some of the observations, notes memo.
In Windows R2 IIS 7.5, for example, there are two areas of the Web site management interface that can customize the error page, the above ASP. NET error pages in the above-said IIS area, and the following:
The two settings interfaces are a bit different, try each with an HTTP 404 setting, but directed to different Web pages,. NET Error pages, pointing to/notfound/systemweb404.html:
Error pages pointing to/notfound/systemwebserver404.html
The setting results in Web.config,.net Error pages are written into System.web/customerrors,error pages and are written to system.webserver/httperrors:
typography shows pure text
<?XML version= "1.0" encoding= "UTF-8"?><Configuration> <system.web> <customErrorsMode= "On"> <ErrorStatusCode= "404"redirect= "/notfound/systemweb404.html"/> </customErrors> </system.web> <system.webserver> <urlcompressiondodynamiccompression= "true" /> <httperrors> <RemoveStatusCode= "404"Substatuscode= "-1" /> <ErrorStatusCode= "404"Prefixlanguagefilepath=""Path= "/notfound/systemwebserver404.html"Responsemode= "Executeurl" /> </httperrors> </system.webserver></Configuration>
What is the difference between these two settings? Simply, access the static files such as. js,. html,. css,. jpg ... The mistake will be made according to HttpErrors; NET processor takes over the URL (for example:. aspx,. ashx,. svc, MVC Registration route), and when it's wrong, look at the settings in customerrors.
The following is a simple example, the input does not exist in the blah.gif see is systemwebserver404.html, the input does not exist blah.aspx is systemweb.404.html, it is proved.
Supplement: HttpErrors has a errormode, is expected to detailedlocalonly, as customerrors mode= "RemoteOnly", so in this machine will not see the custom wrong page, You have to change it to be a custom to see it. This is the line that IIS 7 joins, and the brain that is still in IIS 6 does not realize that there is a difference, it takes a little time to get it done, especially to remember a pen.
[The difference between Asp.net]web.config's customerrors and httperrors