Hi all, is there a way to trap for this error?

Posted on 2009-04-21
Last Modified: 2012-05-06
Hi all,

I get this message on one of my websites when a user logs in, it happens very rarely - what I have on the page is two text boxes and a button which runs code to validate the user logging in against an access database, so nothing super fancy. I've added the solution posted here in to the web.config file, but there's no way for me to test if this error ever comes up, so I'd like to build in some kind of error trap if its possible?
Question by:Zoooink
    LVL 15

    Expert Comment

    You can use the Application_Error in your Global.asax to get the error. Then just log it a text file.
    LVL 3

    Author Comment

    I don't have a global asax file?? What is the purpose of the file?

    Also, how can a show a user friendly message instead of the standard error page that comes up??
    LVL 15

    Accepted Solution

    global.asax is a file that sits in the root of your web app. It allows you to hook events such as a new session being created, errors occurring etc.

    For a friendly error page, you could use the customErrors element in your web.config:

    Add error pages to your application, ie. 404.aspx & 5xx.aspx

    404.aspx would show a Page Not Found message
    5xx.aspx would show a friendly message saying an error occured. You would also log the error in this page so you know what went wrong using the Server.GetLastError() method.

        <customErrors mode="RemoteOnly" defaultRedirect="/5xx.aspx" redirectMode="ResponseRewrite">
          <error statusCode="404" redirect="/404.aspx"/>

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 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

    15 Experts available now in Live!

    Get 1:1 Help Now