0

We have a global exception class, which grabs all exceptions in the web application. General response is to redirect the user to error page.

Now when an exception is raised from Update panel, response.redirect throws an exception saying Server cannot clear headers after HTTP headers have been sent. with this stack trace:

at System.Web.HttpResponse.ClearHeaders() at System.Web.Handlers.ScriptModule.EndRequestHandler(Object sender, EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I have already tried, 1. JS script 2. clearing header and content

3 Answers 3

0

Interesting issue. I've never had that before but this is what I found

http://aspdotnetcodebook.blogspot.com/2008/03/using-responseredirect-in-aspnet-ajax.html

Hope that helps.

1
  • worked upon it already, also I dont have any reference to page. Page = new Page will not work either. Is there a way I can cause a postback before re-direction. Feb 9, 2012 at 9:31
0

I believe you can tap into the page request manager to handle async postback errors.

http://msdn.microsoft.com/en-us/library/bb383810.aspx

 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args)
{
    if (args.get_error() != undefined)
    {
       var errorMessage = args.get_error().message;
       args.set_errorHandled(true);
       ToggleAlertDiv('visible');
       $get(messageElem).innerHTML = errorMessage;
    }
}
0

How is that global-exceptions class being executed? from within global.app_error?

Besides, you might have added true as the 2nd arg to Response.Redirect - which ends the response quickly (before your app_error executes). That means that the server is done sending bytes to the client: it already calculated the response-length, included that value in the response header, and the response headers have already been shipped to the client. You cannot undo that (by clearing them, or anyhow).

If that's the case (true arg), then try setting it to false (or not providing 2nd arg), and see what happens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.