views:

93

answers:

3

Similar question: Link

The question above is partly what I'm looking for except that it seems very VERY verbose instead of being MVC2-ey. Maybe with MVC2 there is a simpler more 'convention over configuration' approach?

How can I easily set up my MVC2 application to show a particular 404 page when a user types in a non-existant view?

Thank you.

A: 

Setup a redirect 404 handler to your custom url on your favourite webserver. also you have to return a proper 404 status header from your view

Frost.baka
A: 

There is a really easy way that might help:

In Web.config

<customErrors mode="On" >
      <error statusCode="404" redirect="404.html" />
      <error statusCode="500" redirect="500.html" />
</customErrors>

I put 404.html and 500.html but you could put any link to any controller/action.

Lobsterm
A: 

It's my experience, that there really isn't a simple way to do this (adding custom errors to web.config just doesn't cut it, mainly because MVC always (or almost always) returns 500 on any unsuccessful request). The link you posted is pretty much the best way, tho it has some variations (for example you can handle 404 exceptions with an attribute instead of modifying the controller factory).

Necros