<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?
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>.
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".
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.
You have to have mode="On"
instead of mode="Off"
<customErrors mode="On" defaultRedirect="~/default.aspx"></customErrors>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With