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.
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.
4. The @: sequence indicates that the line of content that follows should be treated as a content block: ("razor at colon" in Google).
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.
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
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