https://imgur.com/HMwE70d public class ErrorController : Controller { public PartialViewResult Index(string message) { ViewBag.ErrorMessage = message; return PartialView("_Error"); } } protected void Application_Error(object sender, EventArgs e) { Exception exception = Server.GetLastError(); if (exception != null) { HttpException httpException = null; if (exception is HttpException) { httpException = exception as HttpException; } Response.Clear(); Server.ClearError(); Response.Redirect(String.Format("~/Error/Index/?message={0}", HttpUtility.UrlEncode(exception.Message))); //Response.Redirect(string.Format("~/Error/Index/?message={0}", "", HttpUtility.UrlEncode(exception.Message))); } } <html> <head> <meta name="viewport" content="width=device-width" /> <title>Index</title> </head> <body> <h3>@ViewBag.ErrorMessage</h3> </body> </html>
HttpException httpException = null; if (exception is HttpException) { httpException = exception as HttpException; }
HttpException httpException = exception as HttpException;
httpException
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)