Hi
Error message not displaying correctly in layout page.
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>
Thanks