views:

1063

answers:

3

Currently we're opening a new aspx page with window.open. The window.open is in a javascript function (openNewWindow()) in the current aspx page which is called when an asp.net hyperlink control is clicked.

The links are dynamically created on the page by our framework and so I'd like to avoid changing that functionality.

The problem seems to be that when this new 'child' window is closed, session state is lost. I should mention that session is available in the child window just not in the 'parent' window after the 'child' window is closed.

Funnily enough, it seems that elsewhere in our application, if an open.window call is added to a page by using a ClientScriptManager.RegisterStartupScript call on the codebehind click event of a hyperlink control (rather than it calling a function that is coded in the aspx) session is preserved.

The latter solution would be difficult to implement in the current framework code without a significant change and all the regression testing that would entail.

Anybody got any ideas how to keep the session state alive after the close of the child window.

BTW this is occurring in IE7 and our app is asp.net 2.0 based.

Thanks in advance for your insightful and elegant solutions to this problem! ;o)

A: 

Edit: Whoops -- sorry, I click answer instead of comment

I'm sorry that I don't have an answer, but I am experiencing a similar issue, though it is intermittent and I can't successfully duplicate it.

I have a customer who keeps getting redirected to our login page after a new browser window is opened -- for printer friendly pages, dynamic links. This is occuring when using a link with the target set to _blank. I actually had this happen on my workstation a couple of times when building the app, but I haven't been able to duplicate it since.

Thanks to whoever can provide some insight/solve this.

A: 

I should correct myself (sorry can't edit the original question) and say that the control firing the javascript to do 'window.open' is a link button not a hyperlink.

+1  A: 

IE 7 changed the behavior of new windows. Basically, each window is opened in it's own process. Tabs are still opened in the same process.

This means that each new window will have it's own cookie bag. Which means that the new window does not have the Sesssion_ID cookie automatically assigned. The .Net link control will send the cookies to the new window. However, just opening a new window with straight javascript probably won't do that.

FireFox has been this way for awhile, and Chrome, I believe, has always been this way. IE 6 and previous shared process space, even for multiple windows so everything was shared between the two which caused no end of headaches for debugging sites strictly in IE.

UPDATE
Here's a link that describes the problem in detail. You'll notice that this behavior is somewhat inconsistent. The reason is that sometimes IE 7 decides to open the new window in its own process, and sometimes it opens it in a new one.

There are two real solutions. Either stop relying on session entirely (my first choice, and I have strong technical reasons for this) or you need to switch to a cookie-less session.

Chris Lively