简体   繁体   中英

Response.Redirect - Application_EndRequest

I have a weird behavior in my app's prod environment. Prod env has 3 servers and in one of the servers, page redirection causes the Application_EndRequest event to be fired; other two works as expected. I want to avoid the EndRequest event to be fired on page redirect. I am using Response.Redirect(url). I tried using Response.Redirect(url, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Both of them triggers the Endrequest event. I am not sure whether its specific to that server alone.

The real problem is key session variables are reset when the application starts over again during Response.Redirect is executed which causes the application to error out. Is there a way to find the real cause of this problem? I am trying to solve this for past two days but no success.

My Prod severs are 64bit.

Can anyone help in this regard? Your help is greatly appreciated. Thanks. ~/Ananth

Unless I'm misreading the documentation (which is possible), I would say it functions as designed.

Redirect calls End which raises a ThreadAbortException exception upon completion.

and

HttpResponse.End Method
Sends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event.

and

HttpApplication.EndRequest Event
Occurs as the last event in the HTTP pipeline chain of execution when ASP.NET responds to a request.

You say "redirect here." ASP.NET writes the appropriate header to the stream. Request is done, EndRequest should execute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM