I am deploying a MVC3 application on IIS 7.5.
There are some errors which only occur on IIS 7.5, and I am attempting to debug them. However, whenever an error is triggered, the default error.cshtml is shown.
Is it possible to show detailed error messages, similar to how errors are handled in Visual Studio 2010?
How do I pass in exception details to error.cshtml when using the OnHandleError attribute?
Your Error.cshtml
view should accept a model of type HandleErrorInfo
. You can get the exception detail from the Model.Exception
property.
For example, your view might look like:
@model System.Web.Mvc.HandleErrorInfo
@{
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>
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With