Thanks Mattc,
That's a good idea. But this the way we used to do in ASP what is the best
way we can do it in ASP.Net
One more I am allowed to use session then how do I show the error on the
next page, If I pass it through a querystring that is not a good way...
then what are other options I have.
Can I use Context.Handler or something like this...
One more I am trying to avoid writing the even log entry or writing in a log
file as if there is any problem in the global.asax this will halt my entire
application
What is Industry standard/ best practices for this?
Thanks once again
Shailesh G
"MattC" <m@m.com> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
What you should do then is capture the error in the Application_OnError
method in Global.asax. Handle you excecption here and place whatever you
need in the Session object. Server.ClearError then transfer the user to your
custom page. Here you can pull out you details from the Session/send emails
etc.
Alternatively just log the error in the event log. Then set customErrors
mode to RemotrOnly and redirect to your nice friendly page.
MattC
"SMG" <SM*@nodmain.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi MattC,
It says:::
System.NullReferenceException: Object reference not set to an instance of
an object. "error is at the star(*) "
Exception myError =Server.GetLastError();
*string str = "Error Message :" + myError.Message;
My mode of customErrors is Off so that it shows the error on the screen
Objective : If we get any error on any of the pages through out the site,
then it should show a single customize page where
the error is explained and a email is shooted at one id.
Regards,
Shailesh Gajare
"MattC" <m@m.com> wrote in message
news:eI**************@TK2MSFTNGP15.phx.gbl...
What error is it giving? Do you have any error handling in your
global.asax.(vb/cs).
Place try..catch block around GetLasterError to see what exception is
being
thrown.
MattC
"SMG" <SM*@nodmain.com> wrote in message
news:eB**************@TK2MSFTNGP10.phx.gbl... Hi ,
Sory for incomplete message in last post here is the actual problem..
I am using following code in web.confiig for trapping all the error
through
out my site..
<customErrors mode="On" defaultRedirect="WebForm1.aspx">
<error statusCode="404" redirect="ServerError.aspx"></error>
<error statusCode="500" redirect="WebForm3.aspx"></error>
</customErrors>
It works very fine... but On the final page e.g WebForm3.aspx I want
catch
the error and want to show it on the screen.
so i wrote following code in webform3.aspx but it throws an error
// Create an Exception object from the Last error
//that occurred on the server
Exception myError =Server.GetLastError();
// Get the error message
string str = "Error Message :" + myError.Message;
It doesn't work it gives an error at following line
strErrorMsg += "\n\nError Message :" + myError.Message;
Regards,
Shailesh Gajare