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

Posted on 2009-04-21
Medium Priority
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
  • 2
LVL 15

Expert Comment

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

Author Comment

ID: 24203058
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

oobayly earned 2000 total points
ID: 24203136
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


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses
Course of the Month8 days, 16 hours left to enroll

621 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