Custom route for specified errors in web.config

224 views Asked by At

I'm having this custom error config in my web.config :

<customErrors 
  mode="On"
  defaultRedirect="/common/ErrorPage.html?webconfig">
</customErrors >

Now I'm having the need to redirect to a different error page for some special pages but remain the "/common/ErrorPage.html?webconfig"> like default. Is this possible ?

1

There are 1 answers

1
farid bekran On

If your special pages can be in specific ASP.NET MVC area, one way of doing this can be using different location based custom error paths. (from this)

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