views:

36

answers:

2

Hi,

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 ?

A: 

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:

  • On – error details are not shown to anybody, even local users. If you specified a custom error page it will be always used.
  • Off – everyone will see error details, 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 a stack trace and compilation details, while remote users with be presented with a concise page notifying them that an error occurred. If a custom error page is available, it will be shown to the remote users only.
tonythewest
I have this in my web.config <customErrors mode="RemoteOnly" defaultRedirect="~/404.aspx"> <error statusCode="404" redirect="~/404.aspx" /> </customErrors>
UXdesigner
thanks, i modified my webconfig quickly. I added this: <customErrors mode="On" defaultRedirect="~/404.aspx"> </customErrors> But it's pretty much the same. :/
UXdesigner
@UXdesigner - I hope you edited the existing customErrors setting, and didn't add a second.
Greg
It is the existing one, didn't add a second.
UXdesigner
+1  A: 

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

Kev
that was the firs option I tried. But whatever I write, a yellow callout appears with the following message : Wrong URL Format. Please enter an absolute URL within the site.
UXdesigner
IfI type anything in the url without the .aspx extension, it will show an error message, and if i type any page name and add the .aspx extension, it will come with the nice error page. weird thing. don't know what else to do.
UXdesigner
@UXDesigner - see my updated answer.
Kev
Kev. You were right. you solved the issue. This is the accepted answer. I was using "~/404.aspx".
UXdesigner