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

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?
LVL 3
ZoooinkAsked:
Who is Participating?
 
oobaylyCommented:
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.
http://msdn.microsoft.com/en-us/library/2027ewzw.aspx

For a friendly error page, you could use the customErrors element in your web.config:
http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx

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"/>
    </customErrors>

Open in new window

0
 
oobaylyCommented:
You can use the Application_Error in your Global.asax to get the error. Then just log it a text file.
0
 
ZoooinkAuthor Commented:
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??
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.