views:

295

answers:

2

On my site, a broken link throws the default, page not found error. In the web.config I have turned on CustomErrors and forward 404 errors to a custom message.

On my dev box it works, on the host it does not.

Any ideas? ASP.NET MVC 1.0, SQL 2005, IIS 6 host (ya, I wish it was IIS7 - but they want to charge me to move the site).

Thanks in advance!

+1  A: 

CustomErrors will only fire for files which .NET is actually assigned to handle. On your local Visual Studio this covers everything, but in IIS6 it only covers the files that are actually directly related to .NET (.aspx, .ashx, .asmx etc). This means that if you want it for everything you have to add an ISAPI filter to bind all files to be handled by .NET, which comes with overheads and can cause some unexpected behavior if you have any global handlers or HttpModules defined.

This page will help you with configuring a wildcard binding if that's the road you want to go down

Have you considered putting it in the IIS6 configuration instead of .NET? This may be simpler for you than trying to use the CustomErrors from .NET in IIS6.

As a sidenote IIS7 integrated pipeline mode does not have these issues and all files are handled by .NET by default.

Tim Schneider
I was afraid you were going to say that... I'll work around it by setting a 404 file based error page that redirects to my MVC error page, and setup the config in the control panel. Sort of roundabout, but should work. Thanks!
Chad
+1  A: 

It is possible a machine.conf setting is overwriting your web.config setting. Have you contacted your host and asked them if they overwrite the CustomErrors tag?

Radu094
Thanks, I'm pretty sure it's what fyjham described.
Chad