This article will show you how you can manage a common error page in asp.net MVC. In this i will show you how you can show the technical error when some error occur in your mvc website user will be redirected to the error page directly to the error page where he will be able to get all the error detail, What the the error why the error have been occur in the application. in which line error have been occur.
Some of my previous articles are as follows: Passing Controller Action Error to View In MVC, The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at, Error In Visual Studio 2013: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery', Error Handling in Windows Application Using C#.Net, Multiple controls with the same ID '_header' were found. FindControl requires that controls have unique IDs. in Asp.net.
Now lets check the error.cshtml file code.
@model System.Web.Mvc.HandleErrorInfo
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Error</title>
</head>
<body>
<hgroup>
@{
ViewBag.Title = "Uh-oh, an error
occurred/";
}
<h2>One of us broke
the site!</h2>
@if (Model != null)
{
<h3>@Model.Exception.GetType().Name</h3>
<pre>
@Model.Exception.ToString()
</pre>
<p>
thrown in @Model.ControllerName @Model.ActionName
</p>
}
</hgroup>
</body>
</html>
|
0 comments:
Please let me know your view