Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 735
Boo Avatar asked Dec 08 '10 12:12

Boo


People also ask

How do you handle errors in razor view?

How to handle errors in Razor Syntax? As you know razor allows you to full implementation of c# or vb so you can use exception handling inside razor syntax with try, catch, finally block.

What does @: mean in razor?

4. The @: sequence indicates that the line of content that follows should be treated as a content block: ("razor at colon" in Google).

What is error Cshtml?

cshtml as the view not found in Index but in the web. config file. The error statusCode="404" means that the file is not found and it means the controller name or controller action method name is the issue. [HandleError] //If I put in this attribute and run, it will go to the Customized by a Default error page.


1 Answers

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
like image 186
Darin Dimitrov Avatar answered Oct 09 '22 08:10

Darin Dimitrov