Aspdotnet-Suresh

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

Asp.Net Set Custom Error Page in Web.Config

Jul 20, 2016
Introduction

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


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


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

<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="/404.aspx" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
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 Asp.net, C#.net, 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

1 comments :

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 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.