Advice on the best practice please...

N

Nemisis

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
 
P

paulshannon

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
 
P

palfery

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
 
M

Mike Hofer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top