Home > Archive > ASP .NET > May 2007 > Try-Catch error handling
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Try-Catch error handling
|
|
| Blasting Cap 2007-05-30, 7:10 pm |
| 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
| |
| rjdevereux 2007-05-30, 7:10 pm |
| 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
>
| |
| Bjorn Sagbakken 2007-05-30, 7:10 pm |
| 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" <goober@christian.net> wrote in message
news:%23Bs0bptoHHA.1240@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
| |
| Blasting Cap 2007-05-30, 7:10 pm |
| 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" <goober@christian.net> wrote in message
> news:%23Bs0bptoHHA.1240@TK2MSFTNGP06.phx.gbl...
>
>
| |
| Blasting Cap 2007-05-30, 7:10 pm |
| 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:[color=darkred]
> Bjorn:
>
> Did you have any examples of this code online?
>
> Thanks,
>
> BC
>
> Bjorn Sagbakken wrote:
| |
| Bjorn Sagbakken 2007-05-31, 7:10 pm |
| 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" <goober@christian.net> wrote in message
news:e4zubivoHHA.4192@TK2MSFTNGP06.phx.gbl...[color=darkred]
>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:
|
|
|
|
|