Page.Error handler returning a blank page

  • Thread starter Thread starter David R
  • Start date Start date
D

David R

I've been following the "ASP.NET Custom Error Pages" article
(http://www.aspnetresources.com/articles/CustomErrorPages.aspx), but when I
implement either subscribing to base.Error or overriding base.OnError an
empty page is returned to the client browser.

During debugging, the event fires fine, and the page has the right controls
loaded, but ASP.NET just isn't rendering them (So a blank page is returned
to the client browser).

This is what I've got:

public MyPage() {
this.Init += new EventHandler(Page_Init);
this.Error += new EventHandler(Page_Error);
}

private void Page_Init(object sender, EventArgs e) {
try {
// Load a bunch of controls and add them to the page
} catch (Exception Ex) {
Load500(Ex);
}
}
protected override void OnError(EventArgs e) {
Load500( Server.GetLastError() );
Server.ClearError();
base.OnError (e);
}

/* private void Page_Error(object sender, EventArgs e) {
Load500( Server.GetLastError() );
Server.ClearError();
base.OnError(e);
} */

(The second function is commented out)

Load500 is a function that takes an Exception and converts it to a text
string before adding it to the control tree.

Any ideas?

Thanks
 
Dumb question - Are you doing the

HttpContext ctx = HttpContext.Current;
..
..
ctx.Response.Write (errorInfo);

that is mentioned in the article?

Regards
Pandurang
 
I'm not calling Response.Write() at all, I'm just subscribing to the event.

....does the context get restarted when there's an error or something?
 
Back
Top