0

I used Shay Jacoby's solution to route 404s and 500s and it works great on my dev box: How can I properly handle 404 in ASP.NET MVC?

However, in production, it only routes 500 errors and 404s still get the default iis 404 messages. I think I'm missing something simple, any ideas?

I deployed the code to a local iis7 website and the 500 errors are being redirected. I can't think of what is different in the environments. Production is also iis7 and the code is identical.

Thanks

Community
  • 1
  • 1
user376456
  • 2,763
  • 2
  • 20
  • 12
  • update: I changed the 404 error page in IIS to point to my Error/http404 controller action. This seems to work. But I dont understand why the 404 case is not caught in application_error. – user376456 Jun 25 '10 at 18:19

1 Answers1

0

The .Net runtime won't even see the 404.

IIS uses the file extension to determine which IIS handler will process the request.

So, the only way for your app to handle 404's is to have IIS configured to send it directly to your app instead of handling it internally. Which is what you've done.

You might want to check out this question / answer for a few more details.

Community
  • 1
  • 1
NotMe
  • 87,343
  • 27
  • 171
  • 245