MVC 3 Custom / Http Error Pages Not Displayed for Exception View

I have custom / http errors installed in an ASP.NET MVC 3 application that will display on errors. My Web.Config httpErrors section is as follows:

  <httpErrors errorMode="Custom" existingResponse="Replace"> <remove statusCode="400" /> <remove statusCode="403" /> <remove statusCode="404" /> <remove statusCode="408" /> <remove statusCode="500" /> <remove statusCode="503" /> <error statusCode="400" responseMode="ExecuteURL" path="/Error/BadRequest" /> <error statusCode="403" responseMode="ExecuteURL" path="/Error/Forbidden" /> <error statusCode="404" responseMode="ExecuteURL" path="/Error/NotFound" /> <error statusCode="408" responseMode="ExecuteURL" path="/Error/Timeout" /> <error statusCode="500" responseMode="ExecuteURL" path="/Error/InternalServerError" /> <error statusCode="503" responseMode="ExecuteURL" path="/Error/ServiceUnavailable" /> </httpErrors> 

I did not set the customerErrors parameter, as this does not work very well with MVC and IIS 7.5.

Everything works fine when an exception occurs in the code.

However, when an exception is thrown in the view, it tries to show the default value ~/Views/Shared/Error.cshtml , which I do not have.

The view that may cause the error may be as follows:

 @Html.Partial("TemplateSection", Model.PreContent) 

And imagine the PreContent value is null, and the TemplateSection view will not be displayed when the values ​​are displayed by doing the following: @Model.Name

+6
source share
1 answer

I read this article and had no problems since dumping my received code into production 48 hours ago. Give him a whirlwind.

+1
source

Source: https://habr.com/ru/post/917132/


All Articles