views:

40

answers:

3

I've created a web site with ASP.NET 2.0 and I'm using a session variable to determine if a user has filled out an age verification form. Everything works as expected (I can read the session variable on all pages) until a user goes to a virtual directory. When they do so, the page can't read the session variable.

After much research, I've so far done the following.

  1. Turn on the ASP.NET State Service
  2. Added a sessionState node to my web.config files, changing the mode to StateServer (for the web site and virtual directory).

    <sessionState mode="StateServer" cookieless="false" timeout="20" stateConnectionString="tcpip=127.0.0.1:42424" />

  3. Generated a new machineKey and added it to both the site and the virtual directory...

    <machineKey
    validationKey="...128..."
    decryptionKey="...64..." validation="SHA1" decryption="AES" />

  4. Created a new application pool and made sure both the web site and it's virtual directory are using the same application pool.

If I write out the session id <%= Session.SessionId %> it is the same on pages in and out of the virtual directory (it's the same throughout the site). I just can't get that session variable! Does anyone know what else I can try to get this to work??

Thanks.

A: 

Could this be it? http://support.microsoft.com/kb/173307

David
A: 

Different virtual directory = different application and applications don't share session data between them. Perhaps a redesign of your applications to avoid this?

Here is a possible solution to sharing session data between ASP.NET applications.

Passing session data between ASP.NET Applications

DaveB
I've thought about setting a cookie instead of a session variable since it's all under the same domain name, but it just seems like there should be a solution. I thought for sure the session state thing would work... why does it work for server farms but not a virtual directory?
Craig
@Craig - I have never worked with server farms but I think the answer is still that the application(virtural directory) is the same, just located on different servers.
DaveB
A: 

From everything I can tell, it's not possible to do what I wanted to do. What's worse, I decided to use cookies instead of session variables, thinking that since cookies are created and maintained by the client and based on the domain, that would work. Unfortunately, somehow when created with C#/ASP.NET even cookies can't be shared. So I had to use C# to insert Javascript to create cookies so I could do what I wanted. End result is an inelegant solution to what should be a simple problem (IMHO).

Craig