In ASP.NET MVC, how does response.redirect work?
Posted
by Swoop
on Stack Overflow
See other posts from Stack Overflow
or by Swoop
Published on 2010-05-12T20:35:05Z
Indexed on
2010/05/12
20:44 UTC
Read the original article
Hit count: 175
asp.net-mvc
|response.redirect
I have used response.redirect in classic ASP and ASP.NET webforms. However, with MVC 2.0, I am running into something peculiar.
I have a private method in a controller class that is used by multiple controller methods to help load and validate some information. This private method is setup to redirect if a problem is discovered to a generic error message page.
The big problem I am noticing is that the calling controller class and page view attempt to complete rendering and loading before the redirect actually takes place. This is annoying in development because the View throws exceptions that I need to ignore before my generic error page finally loads.
As mentioned above, I am used to the older model of response.redirect which prevented subsequent code on a page from being executed as the new page would then load.
Any help or advice on redirects in MVC would be greatly appreciated.
© Stack Overflow or respective owner