Does Response.RedirectPermanent(); process code after it is called
asp.net-mvc-4, http-status-code-301, redirect
Solution
Ok so as it turns out this is the standard behaviour as `RedirectPermanent` has 2 overloads (I never saw the second overload as my VS was playing up):
Response.RedirectPermanent(string url);
Response.RedirectPermanent(string url, bool endResponse);
The option of `endResponse` says that the permanent redirect will continue to finish the response or end the process immediately after the redirect.
The default is set to false meaning that the first overload (which is what I have used) will finish the response which is why it is calling the `LogError` function
Problem
I have the following code which checks an exception and if it is a 404 exception, it will check a list of urls to see if the page has been moved and if it matches, will issue a permanent redirect to the new page: ``` protected void Application_Error(object sender, EventArgs e) { var exception = Server.GetLastError(); if (exception != null) { if (exception is HttpException) { TryRedirect((HttpException)exception); } LogError(exception); } } private void TryRedirect(HttpException httpException) { if (httpException.GetHttpCode() == 404) { WebsiteRedirect redirect = SiteCache.Redirects.FirstOrDefault(x => string.Compare(x.LegacyURL, HttpContext.Current.Request.RawUrl, true) == 0); if (redirect != null) { // 301 it to the new url Response.RedirectPermanent(redirect.NewURL); } } } ``` Now I would expect that after the redirect has happened, non of the code after it would be executed ie the `LogError` function wouldn't be called. But it seems to be as I am getting error messages for the pages not being found. Is this standard behaviour for MVC `Response.RedirectPermanent`?