By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

Advice on the best practice please...

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.