user156888
user156888

Reputation:

asp.net mvc throw 404 from controller factory

We throw a 404 from the factory if we can't find the controller in the container. However this results in the standard error page not our custom error page. It's like throwing a 404 here bypasses normal error handling. Is this expected?

Upvotes: 0

Views: 622

Answers (1)

Pelle
Pelle

Reputation: 2785

Try adding defaultRedirect="Home/Error" to the <customErrors> section and make sure you have an action method named Error on some controller, in this sample I used Home. I tried throwing a 404 from a custom ControllerFactory with this setup and I got the expected error view.

Upvotes: 1

Related Questions