bduhaish
asked on
<customErrors defaultRedirect="DefaultError.htm" mode="On" />
hi
in the web.config
<customErrors defaultRedirect="ErrorPage .aspx" mode="On">
</customErrors>
------------you now the rest------------------
in ErrorPage.aspx i displayed a frindly label like label1.text = "Errors"
is there a way to now at lest the error code or the number code or a simple discription about the error
any examples in vb.net will be good
thanks.................... ...
in the web.config
<customErrors defaultRedirect="ErrorPage
</customErrors>
------------you now the rest------------------
in ErrorPage.aspx i displayed a frindly label like label1.text = "Errors"
is there a way to now at lest the error code or the number code or a simple discription about the error
any examples in vb.net will be good
thanks....................
I guess if you read this article in detail you will get more details
http://www.developer.com/net/asp/article.php/961301
The GetLastError() method of the Server object simply returns a reference to a generic HttpException. This is a wrapper that was placed around the original exception when it was passed from your ASP.NET page to the Application_Error event. To get access to the original exception, you need to call its GetBaseException() method. This will yield the original exception information, regardless of how many layers have been added to the exception tree.
http://www.developer.com/net/asp/article.php/961301
The GetLastError() method of the Server object simply returns a reference to a generic HttpException. This is a wrapper that was placed around the original exception when it was passed from your ASP.NET page to the Application_Error event. To get access to the original exception, you need to call its GetBaseException() method. This will yield the original exception information, regardless of how many layers have been added to the exception tree.
ASKER
about the first comment were should i type it
You can put in Page_Load of that errorPage.aspx
Sachi
Sachi
ASKER
Sorry but your answer is not clear and about the example in the above link I triad but I get a message say's operator '&' is not defined.
here is the example in the global.asax file
Imports System.Diagnostics
Sub Application_Error(sender As Object, e As EventArgs)
'get reference to the source of the exception chain
Dim ex As Exception = Server.GetLastError().GetB aseExcepti on()
'log the details of the exception and page state to the
'Windows 2000 Event Log
EventLog.WriteEntry("Test Web", _
"MESSAGE: " & ex.Message & _
"\nSOURCE: " & ex.Source & _
"\nFORM: " & Request.Form.ToString() & _
"\nQUERYSTRING: " & Request.QueryString.ToStri ng() & _
"\nTARGETSITE: " & ex.TargetSite & _
"\nSTACKTRACE: " & ex.StackTrace, _
EventLogEntryType.Error)
'Insert optional email notification here...
End Sub
here is the example in the global.asax file
Imports System.Diagnostics
Sub Application_Error(sender As Object, e As EventArgs)
'get reference to the source of the exception chain
Dim ex As Exception = Server.GetLastError().GetB
'log the details of the exception and page state to the
'Windows 2000 Event Log
EventLog.WriteEntry("Test Web", _
"MESSAGE: " & ex.Message & _
"\nSOURCE: " & ex.Source & _
"\nFORM: " & Request.Form.ToString() & _
"\nQUERYSTRING: " & Request.QueryString.ToStri
"\nTARGETSITE: " & ex.TargetSite & _
"\nSTACKTRACE: " & ex.StackTrace, _
EventLogEntryType.Error)
'Insert optional email notification here...
End Sub
In that case you try to put into one single line
EventLog.WriteEntry("Test Web", "MESSAGE: " & ex.Message & "\n SOURCE: " & ex.Source & "\nFORM: " & quest.Form.ToString() & "\nQUERYSTRING: " & Request.QueryString.ToStri ng() & "\nTARGETSITE: " & ex.TargetSite &
"\nSTACKTRACE: " & ex.StackTrace, EventLogEntryType.Error)
"&" is to concat all those value and put into one string.
EventLog.WriteEntry("Test Web", "MESSAGE: " & ex.Message & "\n SOURCE: " & ex.Source & "\nFORM: " & quest.Form.ToString() & "\nQUERYSTRING: " & Request.QueryString.ToStri
"\nSTACKTRACE: " & ex.StackTrace, EventLogEntryType.Error)
"&" is to concat all those value and put into one string.
ASKER
still the same but now it's highlighted on quest.Form.ToString()
ASKER
sorry Rquest.Form.ToString()
huh sorry - It should be -> >>> Request.Form.ToString()
Can you just put this line instead of that line
EventLog.WriteEntry("Test Web", _
"MESSAGE: " & ex.Message & _
"\nSOURCE: " & ex.Source & _
"\nTARGETSITE: " & ex.TargetSite & _
"\nSTACKTRACE: " & ex.StackTrace, _
EventLogEntryType.Error)
EventLog.WriteEntry("Test Web", _
"MESSAGE: " & ex.Message & _
"\nSOURCE: " & ex.Source & _
"\nTARGETSITE: " & ex.TargetSite & _
"\nSTACKTRACE: " & ex.StackTrace, _
EventLogEntryType.Error)
ASKER
I don't get it the namespace is defined but still receiving the same error
c:\inetpub\wwwroot\WebAppl ication11\ Global.asa x.vb(52): Operator '&' is not defined for types 'String' and 'System.Reflection.MethodB ase'.
sachiek what do decide ???
c:\inetpub\wwwroot\WebAppl
sachiek what do decide ???
Can you update me what are namespace you got in your Global.asax.vb?
Sachi
Sachi
ASKER
Imports System.Web
Imports System.Web.SessionState
Imports System.Diagnostics
Imports System.Web.SessionState
Imports System.Diagnostics
Add below line
Imports System
Imports System
ASKER
still ????????????????
I think there is now way, I couldn't finished the steps of this article because this error.
I think there is now way, I couldn't finished the steps of this article because this error.
Pls Can you explain what you are trying to do?
I am quiet missing again what you are trying to do?
I am quiet missing again what you are trying to do?
Please read this article.
Rich Custom Error Handling with ASP.NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/customerrors.asp
I hope you get it right this time,.
Sachi
Rich Custom Error Handling with ASP.NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/customerrors.asp
I hope you get it right this time,.
Sachi
Hi bduhaish ,
There is still more good soultion and simple one avilabe.
http://blogs.msdn.com/mattwag/archive/2005/02/07/368605.aspx
Manually redirect to custom error page.
Sachi
There is still more good soultion and simple one avilabe.
http://blogs.msdn.com/mattwag/archive/2005/02/07/368605.aspx
Manually redirect to custom error page.
Sachi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry for been late ,i was out side the country and the last Comment is clear .
thanks sachiek
thanks sachiek
No probelm.
Sachi
Sachi
Exception ex = application.Server.GetLast
This will give you last error.
Then you can now use ex.Message or ex.ToString() to get relevent info of particular errror.
Sachi