Steven
Would you be able to convert this into VB for me, I understand what you are doing, I just don't know how to replicate it in V
----- Steven Cheng[MSFT] wrote: ----
Hi Gary
After some further research, I found that the problem (can not retrieve the
error info via Server.GetLastError) was caused by the default behavior when
the ASP.NET runtime handling the unhandled exceptions. In fact, after the
"Application_Error" event, the ASP.NET runtime will clear the server error
and then direct user to the custom error page(if the setting is to use
custome error page), however, at that time ,since the server error is
cleared, so we are not able to retrieve it in the custom error page's
Page_Load event
And in the last reply, I told you that we can store the error info in
Session and then retrieve from the Session again in Custom error page's
Page_Load. However, after testing this means, I found it also impossible
because after the Application_Error, the current Session will be stoped and
a new Session is to be started, so all the infos stored in Session also
losed. But I've found another way to retrieve the Server Error info in
custom error page's Page_Load event
Just manually use "Server.Transfer" to forward the current response to the
Custom error page, that'll cause the error info still remain. For example,
here is the code I tested and succeeded
event to custom error page 's Page_Load event
##in Application_Error
protected void Application_Error(Object sender, EventArgs e
Exception ex = Server.GetLastError()
HttpContext.Current.Response.Clear()
Server.Transfer("CustomErrorPage.aspx")
##in CustomErrorPage.aspx 's code behin
public class CustomErrorPage : System.Web.UI.Pag
protected System.Web.UI.WebControls.Label lblCallStack
protected System.Web.UI.WebControls.Label lblSource
protected System.Web.UI.WebControls.Label lblMessage
private void Page_Load(object sender, System.EventArgs e
Exception ex = Server.GetLastError();
lblMessage.Text = ex.Message
lblCallStack.Text = ex.StackTrace
lblSource.Text = ex.Source;
...................
I manually forward the request to the custom erro page rather than let the
ASP.NET runtime do the default hehavior
In addition, here is a tech article on providing custom error handing and
reporting
#Rich Custom Error Handling with ASP.NE
http://msdn.microsoft.com/library/en-us/dnaspp/html/customerrors.asp?frame=
ru
Please try out the above suggestions. If you feel anything unclear, please
feel free to let me know
Regards
Steven Chen
Microsoft Online Suppor
Get Secure!
www.microsoft.com/securit
(This posting is provided "AS IS", with no warranties, and confers no
rights.