![]() |
Page.Error handler returning a blank page
I've been following the "ASP.NET Custom Error Pages" article
(http://www.aspnetresources.com/artic...rorPages.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 -- -David |
RE: Page.Error handler returning a blank page
Dumb question - Are you doing the
HttpContext ctx = HttpContext.Current; .. .. ctx.Response.Write (errorInfo); that is mentioned in the article? Regards Pandurang -- blog: www.thinkingMS.com/pandurang "David R" wrote: > I've been following the "ASP.NET Custom Error Pages" article > (http://www.aspnetresources.com/artic...rorPages.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 > -- > -David > > > > |
Re: Page.Error handler returning a blank page
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? "Pandurang Nayak" <pandurangATthinkingmsDOT(nospam)com> wrote in message news:83AA2334-D389-4B23-B5A6-8CCEE9A06098@microsoft.com... > Dumb question - Are you doing the > > HttpContext ctx = HttpContext.Current; > . > . > ctx.Response.Write (errorInfo); > > that is mentioned in the article? > > Regards > Pandurang > -- > blog: www.thinkingMS.com/pandurang > > > "David R" wrote: > >> I've been following the "ASP.NET Custom Error Pages" article >> (http://www.aspnetresources.com/artic...rorPages.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 >> -- >> -David >> >> >> >> |
| All times are GMT. The time now is 04:39 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.