Page.Error handler returning a blank page

Discussion in 'ASP .Net' started by David R, Mar 22, 2006.

  1. David R

    David R Guest

    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
    --
    -David
    David R, Mar 22, 2006
    #1
    1. Advertising

  2. 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/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
    > --
    > -David
    >
    >
    >
    >
    =?Utf-8?B?UGFuZHVyYW5nIE5heWFr?=, Mar 23, 2006
    #2
    1. Advertising

  3. David R

    David R Guest

    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:...
    > 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/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
    >> --
    >> -David
    >>
    >>
    >>
    >>
    David R, Mar 23, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    740
    John C. Bollinger
    Jan 27, 2006
  2. Replies:
    1
    Views:
    680
    Damien
    Feb 22, 2007
  3. Replies:
    0
    Views:
    338
  4. =?Utf-8?B?R3V1czEyMw==?=

    Repeater control is returning blank textbox

    =?Utf-8?B?R3V1czEyMw==?=, Aug 14, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    619
    =?Utf-8?B?R3V1czEyMw==?=
    Nov 3, 2007
  5. Simulacrom1

    Returning value is blank

    Simulacrom1, Apr 21, 2009, in forum: Javascript
    Replies:
    19
    Views:
    223
    Jeremy J Starcher
    Apr 22, 2009
Loading...

Share This Page