开发者

Show errors in Razor ViewEngine

开发者 https://www.devze.com 2023-01-30 01:44 出处:网络
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 pro开发者_如何转开发cessing your request.Yes, once you

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 pro开发者_如何转开发cessing your request.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消