Multiple sessions generated for a single frameset page?

by Dominic Zukiewicz 12. May 2010 11:09

I was continuing to help migrate some ASP code into .NET. My task this time was to bring the remaining part of the frameset (no, not using Master Pages yet), into .NET. So we have 3 parts:

  • A Frameset page (ASP)
  • Navigation (.NET)
  • Content (.NET)
  • Footer (.NET)

But something odd was happening. When the first page request came in, 3 Global_asax.Session_Start events were generated. This caused major problems, as the frames all used the UserId , via the Session. BUT 3 Sessions were being created, and therefore not sharing any new data that went into it.

The reason this was happening, was that I was using a frameset.asp page. ASP pages are requested as seperate requests because the ASPX pages are maintained by a different handler, .NET. .NET sees the incoming request and says “Do they have a Session cookie?" NO!” and so issues a (random) session cookie to be used.

Now, since ASP is sending 3 simultaneous requests, all without Session cookies, each frame gets its own Session, and its own Session cookie. And so there is a very simple way to fix this: Create your frameset page in ASPX!

.NET will see your frameset.aspx as an initial, single page, issue a Session cookie, and then when the ASPX page issues the requests for the other parts of the page, it will notice the Session cookie and send the pages under the same Session ID.

The result is that you only get 1 single Global_asax.Session_Start.

Tags: , , ,

ASP.NET | ASP

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar