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

Try-Catch error handling

P: n/a
I would like for a page in my app (asp.net framework 2.0, VS 2005) to
both display a message to the user, as well as sending an email when an
error occurs.
I have code in the global.asax.vb codefile to generate an email when an
application error occurs, but is there a way to send an email to me when
this particular page has some sort of a SQL read error (or something
similar)?

I don't want to end the application, I would just like to throw a
message into a label on the page, and have the user continue with the
application, perhaps instructing them to click on a "return" button to
go back to the main menu.

Thanks,

BC
May 30 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I'd be careful putting too much code in your error handling. I beleive the
server.scripttimeout is infinate after an error occured, so your thread could
hang for a long time waiting for the SMTP server.

Other than that, how about putting a try... catch ex as sqlException for
that particular page. Then you keep how you want to handle exceptions on
that page local to the code on that page instead of putting it in global.

"Blasting Cap" wrote:
I would like for a page in my app (asp.net framework 2.0, VS 2005) to
both display a message to the user, as well as sending an email when an
error occurs.
I have code in the global.asax.vb codefile to generate an email when an
application error occurs, but is there a way to send an email to me when
this particular page has some sort of a SQL read error (or something
similar)?

I don't want to end the application, I would just like to throw a
message into a label on the page, and have the user continue with the
application, perhaps instructing them to click on a "return" button to
go back to the main menu.

Thanks,

BC
May 30 '07 #2

P: n/a
I have just done that. I catch serious errors on each form, storing the
information about the error, source and errorcode in a session var. Then I
redirect the user to an error form that just displays the error message in a
nice way, based on the session var. But also, this error form form sends an
email back to me; containing the userID, the part of the application and the
errormessage itself. Very useful, and quite simple.

Bjorn

"Blasting Cap" <go****@christian.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>I would like for a page in my app (asp.net framework 2.0, VS 2005) to both
display a message to the user, as well as sending an email when an error
occurs.
I have code in the global.asax.vb codefile to generate an email when an
application error occurs, but is there a way to send an email to me when
this particular page has some sort of a SQL read error (or something
similar)?

I don't want to end the application, I would just like to throw a message
into a label on the page, and have the user continue with the application,
perhaps instructing them to click on a "return" button to go back to the
main menu.

Thanks,

BC

May 30 '07 #3

P: n/a
Bjorn:

Did you have any examples of this code online?

Thanks,

BC

Bjorn Sagbakken wrote:
I have just done that. I catch serious errors on each form, storing the
information about the error, source and errorcode in a session var. Then I
redirect the user to an error form that just displays the error message in a
nice way, based on the session var. But also, this error form form sends an
email back to me; containing the userID, the part of the application and the
errormessage itself. Very useful, and quite simple.

Bjorn

"Blasting Cap" <go****@christian.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>I would like for a page in my app (asp.net framework 2.0, VS 2005) to both
display a message to the user, as well as sending an email when an error
occurs.
I have code in the global.asax.vb codefile to generate an email when an
application error occurs, but is there a way to send an email to me when
this particular page has some sort of a SQL read error (or something
similar)?

I don't want to end the application, I would just like to throw a message
into a label on the page, and have the user continue with the application,
perhaps instructing them to click on a "return" button to go back to the
main menu.

Thanks,

BC

May 30 '07 #4

P: n/a
I guess what I am asking is there any way to supply the application with
the SMTP server name externally, like passing in a parameter name in a
config file that the app will pick up & be able to use across the
application?

BC
Blasting Cap wrote:
Bjorn:

Did you have any examples of this code online?

Thanks,

BC

Bjorn Sagbakken wrote:
>I have just done that. I catch serious errors on each form, storing
the information about the error, source and errorcode in a session
var. Then I redirect the user to an error form that just displays the
error message in a nice way, based on the session var. But also, this
error form form sends an email back to me; containing the userID, the
part of the application and the errormessage itself. Very useful, and
quite simple.

Bjorn

"Blasting Cap" <go****@christian.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>I would like for a page in my app (asp.net framework 2.0, VS 2005) to
both display a message to the user, as well as sending an email when
an error occurs.
I have code in the global.asax.vb codefile to generate an email when
an application error occurs, but is there a way to send an email to
me when this particular page has some sort of a SQL read error (or
something similar)?

I don't want to end the application, I would just like to throw a
message into a label on the page, and have the user continue with the
application, perhaps instructing them to click on a "return" button
to go back to the main menu.

Thanks,

BC

May 30 '07 #5

P: n/a
I am sure that can be done, even though I haven't done just that in VS 2005
yet.
To open a file and read the content shold be easy, something like declaring
a var as FileSystem, then open the deired file and read the content as text.

Bjorn
"Blasting Cap" <go****@christian.netwrote in message
news:e4**************@TK2MSFTNGP06.phx.gbl...
>I guess what I am asking is there any way to supply the application with
the SMTP server name externally, like passing in a parameter name in a
config file that the app will pick up & be able to use across the
application?

BC
Blasting Cap wrote:
>Bjorn:

Did you have any examples of this code online?

Thanks,

BC

Bjorn Sagbakken wrote:
>>I have just done that. I catch serious errors on each form, storing the
information about the error, source and errorcode in a session var. Then
I redirect the user to an error form that just displays the error
message in a nice way, based on the session var. But also, this error
form form sends an email back to me; containing the userID, the part of
the application and the errormessage itself. Very useful, and quite
simple.

Bjorn

"Blasting Cap" <go****@christian.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
I would like for a page in my app (asp.net framework 2.0, VS 2005) to
both display a message to the user, as well as sending an email when an
error occurs.
I have code in the global.asax.vb codefile to generate an email when an
application error occurs, but is there a way to send an email to me
when this particular page has some sort of a SQL read error (or
something similar)?

I don't want to end the application, I would just like to throw a
message into a label on the page, and have the user continue with the
application, perhaps instructing them to click on a "return" button to
go back to the main menu.

Thanks,

BC


May 31 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.