Boo
Boo

Reputation: 1654

Show errors in Razor ViewEngine

how i can input detailed information about errors? i was trying set customErrors mode to On/Off, but i have only: Sorry, an error occurred while processing your request.

Upvotes: 5

Views: 3669

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039278

Yes, once you enable customErrors it's the contents of the ~/Views/Shared/Error.cshtml file that you are seeing. You can customize it. It is strongly typed to a System.Web.Mvc.HandleErrorInfo model and you can extract the exception inside:

@model System.Web.Mvc.HandleErrorInfo

@{
    View.Title = "Error";
}

<h2>
    Sorry, an error occurred while processing your request.
</h2>

<div>@Model.Exception.ToString()</div>

You also have access to the controller and action that raised the exception inside the model:

@Model.ControllerName
@Model.ActionName

Upvotes: 19

Related Questions