How Can I Redirect To Error Page For Any Specific Error ?

Forums ASP.NETHow Can I Redirect To Error Page For Any Specific Error ?
Staff asked 9 months ago

In my ASP.NET site, I want to redirect to the error page if any specific error comes from any page.

Is there any better option to do the same without checking for errors on each page

Answers (1)

Add Answer
Staff answered 9 months ago

Here is the solution. It seems when you have a location specific customError directive; if you leave the defaultRedirect as “”, it will default to the sitewide defaultRedirect URL.

The solution was simply to turn off CustomError handling for this specific path, like so:

<system.web>
<customErrors defaultRedirect="/Account/ErrorPage" mode="RemoteOnly">
<error statusCode="404" redirect="/Account/ErrorPage" /> //Your File Path
</customErrors>
</system.web>

 

Subscribe

Select Categories