Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to configure Custom Errors in IIS6.

I select the 404 error, set the dropdown to "URL," then enter this as the URL "/404.aspx"

When go to:

http://mysite.com/no-page-here

It finds 404.aspx, but doesn't process it as a .Net page -- it tries to serve up the source as an XML file, then fails because it won't parse.

404s work fine on .Net pages because I set that in the CustomErrors element of the web.config. But for non-.Net resources, I have to use IIS errors, and it refuses to just redirect to the 404 page. It's trying to serve it up the source code, essentially.

share|improve this question

8 Answers 8

Do you have the correct extensions enabled in IIS6? In the IIS manager, go to Web Extensions (usually the last item in the left-hand navigation tree) and make sure that all the appropriate ones are enabled (usually .NET). Otherwise, this is exactly what will happen.

share|improve this answer
    
There's actually nothing in the Web Service Extensions folder, which is odd (it's not my server, actually -- it belongs to a client). However, I'm running an extensive ASP.Net-based site on the server, so I know it will execute .Net code. –  Deane Jul 1 '09 at 21:22
    
Scratch that last comment about there being nothing in that folder -- I had restarted IIS and the MMC had lost its connection. Once I reconnected, there are extensions, and the correct ones are enabled. –  Deane Jul 1 '09 at 21:23

Have you tried putting in the full URL instead of just the "/"? I thought this behavoir happened when you chose "file" and not URL, but perhaps if it is a local URL it bypasses the ASP.Net worker process as well.

share|improve this answer
    
Yes, it's absolutely acting as if I have selected "File," but I promise you the dropdown is "URL." Also odd -- I have the .Net framework wild-carded anyway. So all requests should be hitting th framework and being handled by the CustomErrors defined in the web.config. I have no explanation for that either. –  Deane Jul 1 '09 at 21:37

Sounds like you've got a bug in the error file itself. If you browse to the file does it get served properly or do you get the same symptoms?

share|improve this answer
    
It serves up fine when browsed directly. –  Deane Jul 2 '09 at 19:56

I dont think you can have a dynamic page served up as your 404. If i remember correctly, it needs to be a static page. I guess you could redirect with meta or JS to a dynamic page from there, although that isnt "standard"

share|improve this answer
1  
Nope, not true. You can serve an ASPX up as a custom error in IIS6. –  squillman Jul 1 '09 at 21:46
    
and it will execute? –  NickatUship Jul 1 '09 at 21:50
    
Yep. Was just doing it on my test box to try and replicate the problem at hand. –  squillman Jul 1 '09 at 23:57
    
You've been able to do that for a long time. I've seen custom 404s in Classic ASP too. –  AnonJr Jul 5 '09 at 17:45

This Technet Article says to make sure and choose URL, or risk returning the source code of the page.

This Article explains how you can use the global.asax file to trap all application errors, including 404.

Global.asax needs to have:

protected void Application_Error(object sender, EventArgs e)
{
}

When any exception is thrown now—be it a general exception or a 404—it will end up in Application_Error.

share|improve this answer

What you want is, set the dropdown to URL and then enter '/sitename/404.aspx' where sitename is the root directory of the website.

share|improve this answer

It really acts like you set "File" instead of "URL" - but you didn't. What happens when you insert the whole 404 URL in a browser? If that works, as workaround you could try to insert the complete URL instead of /404.aspx:

http://www.example.com/404.aspx

You mention that this is a customer's server. Make sure, that there are not two web sites pointing to the same physical directory and you're editing the wrong one. Are there more And make also sure that the website is marked as application.

share|improve this answer
    
OP has mentioned that browsing directly to the 404 itself works fine. –  random Jul 6 '09 at 4:33

From the sounds of it your trying to use the web.config to point to a .NET error page. This will only work for .Net pages. If you use a mix of say Classic ASP and .Net you must set IIS errors to point to the file you want. For this you have to have access to the server directly. Or write something in your Global.asa to redirect on errors.

At least thats how I've alsways had to do it.

Edit: Now that I'm thinking about it a little more and did a little digging on my localhost it does not look like you can point the Custom Errors to a .Net page. It does nto appear to use ASP.NET to process those pages which of course is required to render it. You will need to use an HTML page and maybe redirect from there.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.