Error Redirection In ASP.NET

Posted on 2011-10-29
Last Modified: 2012-05-12
Hello Experts -
What is the least complicated way to configure an ASP.NET application to respond to site errors with a 'friendly' error message (as opposed to throwing an Application Error)?  Ideally I'd like to have an 'error.aspx' page with a generic message in it to which the app would redirect in the event that it encounters an error (any error).  Is there a quick and easy way to set that redirect up?  Thanks all.

-- Rick
Question by:MinnRick
    LVL 9

    Accepted Solution

    There is two simple ways : on the IIS server or within the ASP.NET page.

    On IIS Server :
    Within the properties of a website (or at the granularity you want to set it) you can go to the error message tab and set the 500 one to a file of your own.

    In the page :
    Add a try/catch that surrounds the whole code which in the catch you redirect to the page you want.
    LVL 15

    Assisted Solution

    another way to go is altering the web.config customErrors section to match your needs

    Author Closing Comment

    Thanks very much.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now