I've created a 404 error page called 404.aspx which works fantastic when I call it manually. But after setting the "custom error" in web.config and IIS 6.0. It doesn't work properly.
for example, If I type the URL the wrong way, it won't work and a message like 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 type the url like this: http://domain/anything.ASPX (ADDING THE .ASPX) at the end, it will redirect to the custom error 404.aspx correctly and works fine.
What can I do to make this work ?
You can add custom error messages to IIS by adding an <error> element to the <httpErrors> element in the Web. config file for your site, application, or URL.
Step 3: Open “Error Pages.” You can do this by double-clicking “Error Pages,” located in the home pane. Step 5: Enter the HTTP “Status Code.” When you see the dialog box “Add Custom Error Page,” enter “404” underneath “Status Code.” Step 6: Select “Execute a URL on this site,” located in the same dialog box.
Sounds like you've set the IIS custom error page type to File
instead of Url
.
Setting to File
will just cause IIS to render the contents of your error page verbatim to the response stream (i.e. as a static file) instead of doing a HTTP redirect to the error page causing the page to be processed by ASP.NET.
IIS 6 requires that an 'Absolute URL within the site' to be entered if using the URL message type, for example:
/404.aspx
I assume that your syntax is as follows:
<customErrors
mode="RemoteOnly"
defaultRedirect="~/errors/GeneralError.aspx"
/>
To see the custom page yourself set mode to "On"
<customErrors
mode="On"
defaultRedirect="~/errors/GeneralError.aspx"
/>
The modes are defined as follows:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With