Popup Window Loses ASP.NET Session Variables

Posted by Grubersauce

In one of our apps, we have the ability to comsume our website through Windows Forms and open our website in a Windows WebBroswer control.  Everything works great until one of the links opens a new window for printing.  We were doing something similar to

window.open('someurl', ....);

The problem is, the new window loaded the page using content stored in our session variables.  The new window started a new instance of IE (or whatever the default browser is set to) and therefore created a new session for the page.  Scouring the Internets lists some ways to share the session via storing session in the database.  This just wasn't feasible for several reasons

  • The performance hit we take by storing variables in session rather than inproc
  • Having to mark all of those objects as serializable
  • A lot of work for something simple like getting the print button to work

The solution is to change how we are opening the new window to be a modal dialog

window.showModalDialog('someUrl', ....);

Using a modal dialog we still share the session with the parent page.  You may encounter some styling issues, but all in all, a lot better than changing where your session is stored and all the headaches involved in that.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading