User Errors Redefined in ASP.NET MVC Area

I would like custom error pages to be unique to the MVC area. Unfortunately, it seems that the Web.config override system does not take into account the MVC folder structure. If I want to redefine the area called "mobile", I need to create the root folder of the project (in the "Views and controllers" section) with the name "mobile" and put Web.config with the new element there customErrors.

Is there a better way to do this, so that I don't need to create a root folder for any overrides?

+3
source share
1 answer

I was looking for exactly the same thing. One small change I make is to use the location element in the main web.config. This is a matter of preference, I suppose, but it is stopping you from creating a separate folder and file in your solution. I would love to know a better way though.

<system.web>
  <customErrors mode="On" defaultRedirect="error" />
</system.web>
.
.
.
<location path="areaName">
  <system.web>
    <customErrors mode="On" defaultRedirect="/areaName/error" />
  </system.web>    
</location>
+6
source

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


All Articles