aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Asp.Net Set Custom Error Page in Web.Config

Jul 20, 2016

Here I will explain how to set custom error page in web.config in or display custom error page in in case url pattern not matched or redirect to default error page in case non existing pages. By enabling customErrors in web.config file in we can display or redirect to custom error page whenever error throws in application.

To set custom error page in web.config in or redirect to default page in case if there is error in web application we need to write the code like as shown below

<customErrors mode="On" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="404.aspx" />

<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="/404.aspx" responseMode="ExecuteURL"/>
By setting above properties in web.config file automatically it will redirect to custom error page in our application whenever it throws “404” error.

Same way we need to set properties in web.config file for following errors also.

- 400 Error (Bad request)
- 401 Error (Unauthorized)
- 403 Error (Forbidden)
- 404 Error (Not found)
- 500 Error (Internal server error)

Here we used “404.aspx” page in your case you need to give your custom error page to redirect in your application. 

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Unknown said...

Awesome You are and awesome is your post,Keep going guys. Your post are really helpful to all of them who follows you.
I am great following of you i noted down all of your post what you post in FB and Here.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.