.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How we can redirect custome error page if any error occurs in asp.net, Please give samples and do ex

Posted By: Dhivakaran     Posted Date: October 31, 2010    Points:2   Category :ASP.Net
How we can redirect custome error page if any error occurs in asp.net, Please give samples and do expaline the steps?

Responses
Author: Dhiraj Ranka             
Posted Date: October 31, 2010     Points: 5   

You can set that up in web.config as follows

<customErrors mode="on">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />-->
</customErrors>

hope this helps

Hope this helps.

Thanks & Regards,
Dhiraj Ranka
http://www.twitter.com/dhirajranka | http://www.dhirajranka.com
Author: Dhivakaran             
Posted Date: October 31, 2010     Points: 5   

Dear Dhiraj,

i need to redirect custom pages like if I get any DB error or any other error.

i dont want statuscode based on error pages

-
Dhivakaran T
Author: Dhiraj Ranka             
Posted Date: October 31, 2010     Points: 5   

In that case you can design one error page of your choice and in try catch block, when ever web application encounters an exception then redirect to that custom error page with exception details with a link to go back to your main web application

HttpContext.Current.Response.Redirect(url);

hope this helps

Hope this helps.

Thanks & Regards,
Dhiraj Ranka
http://www.twitter.com/dhirajranka | http://www.dhirajranka.com
Author: Ramesh P             
Posted Date: October 31, 2010     Points: 5   

Just use the following code,

<configuration>
<system.web>
...
...
</system.web>

<!-- Configuration for the "Customers" subdirectory. -->
<location path="Customers">
<system.web>
<customErrors mode="On" defaultRedirect="error.htm">
<error statusCode="500" redirect="CustomerError500.aspx"/>
<error statusCode="401"
redirect="CustomerAccessDenied.aspx"/>
<error statusCode="404"
redirect="CustomerPageNotFound.htm"/>
<error statusCode="403" redirect="noaccessallowed.htm"/>
</customErrors>
<authorization>
<allow roles="MYDOMAIN\Customers" />
<deny users="*" />
</authorization>
</system.web>
</location>



Regards,


Ramesh

Author: Ramesh P             
Posted Date: October 31, 2010     Points: 5   

If you want to get db error, Use the following code,

<appSettings>
<add key="ErrorLoggingLogToDB" value="True" />
<add key="ErrorLoggingLogToEventLog" value="True" />
<add key="ErrorLoggingLogToFile" value="True" />
<add key="ErrorLoggingConnectString" value="Initial
Catalog=DotNetErrorLog;Data Source=localhost;Integrated Security=SSPI;" />
<add key="ErrorLoggingEventLogType" value="Application" />
<add key="ErrorLoggingLogFile" value="c:\ErrorManager.log" />
</appSettings>



Regards,


Ramesh

Author: Dhivakaran             
Posted Date: October 31, 2010     Points: 5   

Hi Guys,

Thanks for your prompt response.

-
Dhivakaran T


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend