简体   繁体   中英

ASP.NET CustomError 404

So I have basically setup a customError in the web.config which works fine when an exception occurs in the webservice, but now I want to add another customError which will look for an http 404 error. When the webservice gets an exception the ErrorPage.aspx CustomError works fine and when I enter an invalid URL the Yellow Screen Of Death comes up which I don't want, I want the 404.aspx error to come up.

Here is my code for the web.config

<customErrors mode="On" defaultRedirect="~/ErrorPages/ErrorPage.aspx">
  <error statusCode="404" redirect="~/ErrorPages/404.aspx" />
</customErrors>

This is the URL that returns when I type in the wrong URL

http://localhost:28745/ErrorPages/404.aspx?aspxerrorpath=/Accounfghogin.aspx

And this is the Yellow Screen Of Death I get when typing in the wrong URL

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.

如果尝试将波浪号(〜)替换为文件的完整路径,是否可行?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM