Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show full error messages when hosting MVC application on IIS 7.5

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.

  1. Is it possible to show detailed error messages, similar to how errors are handled in Visual Studio 2010?

  2. How do I pass in exception details to error.cshtml when using the OnHandleError attribute?

like image 733
Extrakun Avatar asked Jul 19 '11 15:07

Extrakun


1 Answers

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>
}
like image 114
Cᴏʀʏ Avatar answered Oct 30 '22 17:10

Cᴏʀʏ