404 User error in IIS 6.0 and ASPX not working

I created a 404 error page called 404.aspx, which works fantastically when I call it manually. But after installing the "user error" in web.config and IIS 6.0. This does not work properly.

For example, if I find the URL incorrectly, it will not work, and a message similar to the one below appears.

XML Parsing Error: not well-formed Location: **http://domain/anything** (without an extension) Line Number 1, Column 2:<%@ page language="C#" masterpagefile="~/Public.master" autoeventwireup="true" inherits="_404, App_We 

And, if I print the url like this: http: //domain/anything.ASPX (adding .ASPX) at the end, it will be redirected to user 404.aspx error correctly and works fine.

What can I do to make this work?

+6
source share
2 answers

It looks like you have configured the IIS File custom error page type instead of Url .

Setting it to File will cause IIS to display the contents of your error page before responding to the response stream (i.e., as a static file) instead of redirecting HTTP to the error page, causing the page to be processed by ASP.NET.

IIS 6 requires that the "Absolute URL within the site" be entered when using the message type of the URL, for example:

/404.aspx

+7
source share

I assume your syntax is as follows:

 <customErrors mode="RemoteOnly" defaultRedirect="~/errors/GeneralError.aspx" /> 

To customize the page yourself, set the mode to "On"

 <customErrors mode="On" defaultRedirect="~/errors/GeneralError.aspx" /> 

Modes are defined as follows:

  • On - Error information is not displayed to anyone, even local users. If you specified a custom error page, it will always be used.
  • Disabled - everyone will see error information, both local and remote users. If you specified a custom error page, it will NOT be used.
  • RemoteOnly - local users will see detailed error pages with information about the stack trace and compilation, and remote users will be presented with a short page with an error notification. If a custom error page is available, it will only be shown to remote users.
+2
source share

All Articles