Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CustomErrors DefaultRedirect to Default.aspx Not Working

<system.web>
    <authentication mode="Forms">
      <forms loginUrl="~/LogIn.aspx" defaultUrl="~/default.aspx" protection="All">
      </forms>
    </authentication>
    <customErrors mode="Off" defaultRedirect="~/default.aspx"></customErrors>
</system.web>

This is my error handling in web.config which is not working. If there is any exception thrown it doesn't redirect to default.aspx page.
Is it because I set defaultUrl to ~/default.aspx? - If not what's wrong with the error handling?

like image 786
levi Avatar asked Mar 11 '13 09:03

levi


People also ask

How do I change the default error page in web config?

Steps for Custom Error Page Add Web Form for custom error page. Set <customErrors> setting in Web. Config file of the application. Pass defaultRedirect and mode attributes in <customErrors>.

Where do you put customErrors mode off?

The customErrors tag must be placed within tags. Create a <customErrors> tag within a "web. config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

What is customErrors mode RemoteOnly?

RemoteOnly will give end users the custom error message and local usrs the standard asp.net error page. If your developers use a local web server for development you have both in one. Another approach is to set the <customErrors> to Off on development servers and set it to On in the production environment.


1 Answers

You have to have mode="On" instead of mode="Off"

<customErrors mode="On" defaultRedirect="~/default.aspx"></customErrors>
like image 77
Adil Avatar answered Oct 14 '22 03:10

Adil