0
votes

I need help with settings. It's never use provided page for error 404.

This is my customErrors web.config block:

<customErrors mode="On" defaultRedirect="/systemerror.aspx">
  <error statusCode="404" redirect="/404.aspx" />
</customErrors>

I have these page created and they works well if I call them by url, but when I write in url non-existent page like:http://www.mysite.com/asdfasdasd I am getting:

Server Error

404 - File or directory not found.

The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

It's not use my custom error page 404.aspx, how can I fix this ?

2

2 Answers

0
votes

If you are using IIS 7, try:

Response.TrySkipIisCustomErrors = true; 

Refer:

HttpResponse.TrySkipIisCustomErrors Property :Gets or sets a value that specifies whether IIS 7.0 custom errors are disabled.

0
votes

You are missing ~

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

This should work. Let me know.