1
votes

I have two web applications hosted on a server using virtual directories created on IIS.

like : 123.12.23.124/site1 , 123.12.23.124/site2

Now i need to access the session created in site1 in site2. This is what i have done so far:

  1. change both site's web.config files to use stateserver session as

sessionState mode="StateServer" cookieless="false" timeout="720" stateConnectionString="tcpip=127.0.0.1:42424"

  1. I went into services and started asp.net state service on the server.

I have set up session as on site1:

session["user"] = "xxxx";

And accessing in site2 as :

if(session["user"] != null)
{
}
else
{
   //Always coming here
}
2
Are the virtual directories running under the same app domain in IIS?Cam Bruce
you must use shared session this link can be use full [Shared Session][1] [1]: stackoverflow.com/questions/2868316/…Mehdi Haghshenas
You can't with default session implementations and no hacks. There are many related questions (i.e. one as suggested duplicate, or stackoverflow.com/questions/623551/… ). Please check related posts out and update your questions with what approaches do not work for you. (Or close as duplicate if you found one you like)Alexei Levenkov

2 Answers

0
votes

You set the session server wrong in web.config,

sessionState mode="StateServer" cookieless="false" timeout="720" stateConnectionString="tcpip=127.0.0.1:42424"

It shouldn't be 127.0.0.1. Find and fill the state server's real ip.

0
votes

It was 2 way for this 1- using shared session that discous in Shared Session 2- using machine key If your problem about authentication ,etc this is very usefull because when you login in one site you logined in other sites on the same server

With manually generated key values, the settings should be similar to the following example.

<machineKey  
validationKey="21F090935F6E49C2C797F69BBAAD8402ABD2EE0B667A8B44EA7DD4374267A75D7
               AD972A119482D15A4127461DB1DC347C1A63AE5F1CCFAACFF1B72A7F0A281B"           
decryptionKey="ABAA84D7EC4BB56D75D217CECFFB9628809BDB8BF91CFCD64568A145BE59719F"
validation="SHA1"
decryption="AES"
/>