This blog post will help you when you receive a client error status code redirect.
Recommended
namespace ExceptionHandlingDemo.Controllers{ public class HomeController: controller Most people ActionResult Contact () Consecutive message = null; ViewBag.Message = msg.Length; This // throws an exception Pay See ();
Public Diversity FilterConfig public old fashioned void RegisterGlobalFilters (GlobalFilterCollection filter) filter.Add (new HandleErrorAttribute ());
Mode = “activated”
Mode = “activated”
Every client always requires error handling. They always want a “friendly” error page to be displayed – their clients / viewers, with the exception of the ASP network. Yellow “Application error in” / “” “You keep” remember what I’m talking about!
As you probably know, ASP.NET has always been simple:
Now, when an error occurs, it will be redirected to an error page or a specific error web page depending on the status code. Great, isn’t it?
404 – Good, 302 – Bad
- Creates a “Found 302” HTTP location, which means our own requested data is actually stored in another suitable URL (redirect URL).
- Really takes you to an error page with an HTTP status of “OK 200”.
You’ll see this a lot in Firebug (or Fiddler) for both sides:
“Whyis it literally that bad? My users always read the user-friendly page! €
Basically, search engines love “hard 404” and improve SEO. Read this google blog post: http://googlewebmastercentral.blogspot.com/2008/08/farewell-to-soft-404s.html
Give Me The Program Already!
We still want to make sure we can use the web.config to manage our error and that messages / pages don’t need to be confused with IIS, so the solution is to catch the error globally. ascx Application_Errror:
protected void Application_Error (EventArgs sender object, e) var config = WebConfigurationManager.OpenWebConfiguration ("~ / Web.config"); var customErrors means config.GetSection ("system.web / customErrors") as customerrorssection; but if (customErrors! = null && customErrors.Mode == CustomErrorsMode. on) var app = (HttpApplication) sender; Exception lastError = app.Server.GetLastError (); var httpEx = lastError as HttpException; if (httpEx! = null) int httpErrorCode = httpEx.GetHttpCode (); The line redirection matches customErrors.DefaultRedirect; (CustomError for every error in customErrors.Errors) if (error.StatusCode == httpErrorCode) route = error.Redirect; app.Server.ClearError (); app.Context.Response.StatusCode HttpErrorCode; according toServer.Transfer is running (redirect, false);
These demos resolve your custom error profile AND return the correct HTTP popularity code (404 not found in any case) AND, due to the generic Server.Transfer method, do not redirect to this error page to set up a redirect.
Recommended
Is your PC running slow? Do you have problems starting up Windows? Don't despair! Fortect is the solution for you. This powerful and easy-to-use tool will diagnose and repair your PC, increasing system performance, optimizing memory, and improving security in the process. So don't wait - download Fortect today!
Everyone’s happy now: your client gets an error handling page, users see a friendly message, and search engines get their status code!
Speed up your PC today with this easy-to-use download.
Kundfel Fel Statuskod Omdirigering
Perenapravlenie Koda Oshibki Oshibki Klienta
Klantenfout Statuscode Omleiding
Blad Customerrors Przekierowanie Kodu Statusu
Error Del Cliente Redireccionamiento Del Codigo De Estado
Customerrors Error Statuscode Redirect
Reindirizzamento Del Codice Di Stato Di Errore Degli Errori Dei Clienti
Kundenfehler Statuscode Weiterleitung
Customerrors Erreur Statuscode Redirection
Customerrors 오류 상태 코드 리디렉션