Page.Error handler returning a blank page

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
 
G

Guest

Dumb question - Are you doing the

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

that is mentioned in the article?

Regards
Pandurang
 
D

David R

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top