469,611 Members | 1,704 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,611 developers. It's quick & easy.

Advice on the best practice please...

Guys,

I would like to write a error handler, or something, that will allow
me to write to a database when an error occurs on my site. I am
trying to implement this in the global.asax file a the moment, but am
having problems when a 404 error occurs, i cant access sessionstate.

Is writing this code in the global.asax file the best way to do this?
I have been searching on the net and hear alot about httphandlers?
Will a httphanlder recognise, when an error has occurred on a page?
Or when a 404 error occurs?

One thing, i do need access to Session variables, as my
connectionstring is stored within a users session variables.

Any advice would be really appreicated. Cheers

Mar 13 '07 #1
3 1806
On 13 Mar, 10:41, "Nemisis" <darrens2...@hotmail.comwrote:
Guys,

I would like to write a error handler, or something, that will allow
me to write to a database when an error occurs on my site. I am
trying to implement this in the global.asax file a the moment, but am
having problems when a 404 error occurs, i cant access sessionstate.

Is writing this code in the global.asax file the best way to do this?
I have been searching on the net and hear alot about httphandlers?
Will a httphanlder recognise, when an error has occurred on a page?
Or when a 404 error occurs?

One thing, i do need access to Session variables, as my
connectionstring is stored within a users session variables.

Any advice would be really appreicated. Cheers
Have you looked at log4net?

http://logging.apache.org/log4net/

We use this, although I've never tried to capture 404's with it.

Regards

Mar 13 '07 #2
On Mar 13, 5:41 am, "Nemisis" <darrens2...@hotmail.comwrote:
Guys,

I would like to write a error handler, or something, that will allow
me to write to a database when an error occurs on my site. I am
trying to implement this in the global.asax file a the moment, but am
having problems when a 404 error occurs, i cant access sessionstate.

Is writing this code in the global.asax file the best way to do this?
I have been searching on the net and hear alot about httphandlers?
Will a httphanlder recognise, when an error has occurred on a page?
Or when a 404 error occurs?

One thing, i do need access to Session variables, as my
connectionstring is stored within a users session variables.

Any advice would be really appreicated. Cheers
we use the global.asax as a catch all for any unhandeled erros. We
then write the error message and stack trace to a text file. You
should be able to store the connection string in the web.config and
use the appsettings or connection strings class to retrieve it in the
global.asax. The web.config is best place to store the connection
string.

David

Mar 13 '07 #3
On Mar 13, 9:18 am, palf...@fvtc.edu wrote:
On Mar 13, 5:41 am, "Nemisis" <darrens2...@hotmail.comwrote:


Guys,
I would like to write a error handler, or something, that will allow
me to write to a database when an error occurs on my site. I am
trying to implement this in the global.asax file a the moment, but am
having problems when a 404 error occurs, i cant access sessionstate.
Is writing this code in the global.asax file the best way to do this?
I have been searching on the net and hear alot about httphandlers?
Will a httphanlder recognise, when an error has occurred on a page?
Or when a 404 error occurs?
One thing, i do need access to Session variables, as my
connectionstring is stored within a users session variables.
Any advice would be really appreicated. Cheers

we use the global.asax as a catch all for any unhandeled erros. We
then write the error message and stack trace to a text file. You
should be able to store the connection string in the web.config and
use the appsettings or connection strings class to retrieve it in the
global.asax. The web.config is best place to store the connection
string.

David- Hide quoted text -

- Show quoted text -
I have to agree with David. Unless each user's connection string is
different, there's no reason to store it in the session. Ideally,
you're using integrated security to connect to the database; in that
case, the connection string is static, and would be best placed in the
Web.config file.

With that in mind, the problem of trying to access the Session object
from your global.asax file goes away.

Mar 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

136 posts views Thread by Matt Kruse | last post: by
2 posts views Thread by Fraser | last post: by
4 posts views Thread by | last post: by
2 posts views Thread by Steve Le Monnier | last post: by
7 posts views Thread by Joseph Geretz | last post: by
3 posts views Thread by anthonykallay | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.