Custom Errors on ASP.Net MVC - redirectMode="ResponseRewrite" Issue
I assume that some of you folks have tried that in your ASP.Net MVC applications and try to figure out why it doesn't work. Well, I have figured it out...
12/8/2010 11:17:17 PM 3 comments 6032 times
Today, I was wraping up an asp.net mvc project. Make it prettier and safer. I realised that there is a thing which doesn't quite work with asp.net mvc. CustomErrors !
I wanted to refill the page, which has one or multiple errors, with a custom error page so I implemented the following code on web.config file;
Then, I hit an error on pupose just in case to see if it works or not and Boom... !! It failed ! It gave me the famous ASP.Net yellow screen of death;
I was a little surprised about that and I wonder why that thing happened. So I made a little research and I opened a thread on ASP.Net MVC Forums
The answer is pretty reasonable for me and I changed the RedirectMode to ResponseRedirect which is the default one.
But I still wonder that ASP.Net Mvc team will fix it in next versions or not....
apperently, the best way of retuning 404 error is to handle them on your controller. I mean, you cannot handle all of them but you can predict that on one conditions this will going to retun a null page so lets throw 404 httpexception.
But insted, create a 404 view and redrecttoview or directly retun the view as partial
thanks for the input.
Keep in Touch with Me