RE: Remote Errors return NULL
From: Steven Cheng[MSFT] (v-schang_at_online.microsoft.com)
Date: 02/04/04
- Next message: Z0gS: "capture window username"
- Previous message: Grey: "deploy Crystal report on web"
- In reply to: Felix Wu [MSFT]: "RE: Remote Errors return NULL"
- Next in thread: Steven Cheng[MSFT]: "RE: Remote Errors return NULL"
- Reply: Steven Cheng[MSFT]: "RE: Remote Errors return NULL"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 04 Feb 2004 02:54:33 GMT
Hi,
Thanks for posting in the community!
>From your description, you used a iframe page in one ASP.NET web
application to contain another page in a different web application.
However, when the inner page(contained in the iframe) run into error, the
error information didnt' display correctly. Also, you've tried use a custom
error page to display error info via the "Server.GetLastError" but still
with no result,yes?
If there is anything I misunderstood, please feel free to let me know.
1. As for the first problem, I agree to Felixwu's suggestion that try
change the <CustomError .. >'s "mode" attribute as "Off" so as to allow
displaying the detailed info of the exception.
2. As for using a custom error page to display the application error. There
are some points we need to take care.
We need to capture the Application_Error event of the Global class and
manually use "Server.Transfer" method to forward the response to the
"customerrorpage". Because by default, when an unhandled exception occur,
after the Appliction_Error event handler, the ASP.NET runtime will clear
the server error also the Session will be stoped and restart and new
Session(you may add some break points in the Global object's certain events
to have a check). So by default, in the custom error page, when we call
"Server.GetLastError()", we will get Nothing(null). So by using
"Server.Transfer" to manually redirect to custom error page in
Application_Error event, the server error info and the request's form
collections will remain so that we can retrieve and display it in custom
error page. For example, here is
what I use to store and retieve the server error from Application_Error
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 behind
public class CustomErrorPage : System.Web.UI.Page
{
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;
}
...................
}
In addition, here is a tech article on providing custom error handing and
reporting:
#Rich Custom Error Handling with ASP.NET
http://msdn.microsoft.com/library/en-us/dnaspp/html/customerrors.asp?frame=t
rue
Please check out the above suggestions. If there're anything unclear,
please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
- Next message: Z0gS: "capture window username"
- Previous message: Grey: "deploy Crystal report on web"
- In reply to: Felix Wu [MSFT]: "RE: Remote Errors return NULL"
- Next in thread: Steven Cheng[MSFT]: "RE: Remote Errors return NULL"
- Reply: Steven Cheng[MSFT]: "RE: Remote Errors return NULL"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|