Click here to Skip to main content
15,946,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Iam sharing session in single database. Using sessionState="SQLServer".

It will work fine, If I host the different applications in the same IIS.

Iam hosting in different IIS, Iam unable to get the session.

SessionId is creating as different for each application.

I got a solution by modified web.config and procedure. I hosted two applications in same IIS, its working fine session is sharing. But I hosted first application in one web server and second application another IIS the session is not sharing.
Did u have experienced on this?

What I have tried:

I tried by hosting the applications in wwwroot.
I tried my giving same applicationname in sessionState variable.
Updated 2-Jan-19 1:18am
Mohibur Rashid 14-Dec-18 5:13am    
Have you considered session server?
nandakishoreroyal 14-Dec-18 5:15am    
F-ES Sitecore 14-Dec-18 5:39am    
The session id is stored in cookies and you can't share cookies across websites so you can't share session either. You'll need to build your own mechanism that allows you to identify the same user such as managing your own custom session cookie.
W Balboos, GHB 14-Dec-18 7:23am    
This would be an incredibly dangerous feature if it existed. You data and personal information can be passed system-to-system for any purpose. Sessions were not designed for this. Consider them a mechanism to keep you client and the server coordinated during the brief periods they must share information - before the server drops interest in you until the next data request.

Data can be transmitted, for example, via the URL across systems.
Nathan Minier 14-Dec-18 7:35am    
There's already a technology classification called SSO (Single Sign On). Consider picking an SSO solution, like Active Directory with Kerberos, rather than trying to implement a system where user impersonation would be trivial.

1 solution

If i understand you well, you are trying to configure MS SQL Server database to store information about session state. If yes, please follow the steps from here: ASP.NET Session State with SQL Server In-Memory OLTP | SQL Database Engine Blog[^]

Seems, that one of the most important things, is:

To configure SQLServer mode for a Web farm, in the configuration file for each Web server, set the sessionState element's sqlConnectionString attribute to point to the same SQL Server database. The path for the ASP.NET application in the IIS metabase must be identical on all Web servers that share session state in the SQL Server database. (...)

If you specify a trusted connection to your SQL Server in the configuration file using the sessionState element's sqlConnectionString attribute, the SessionStateModule will connect to SQL Server using SQL Server integrated security. The connection will be made using the ASP.NET process identity or the user credentials supplied for the identity configuration element, if they exist. You can specify that the IIS impersonated identity be used instead by specifying <identity impersonate="true" /> and setting the useHostingIdentity attribute of the sessionState configuration element to false. For more information on the ASP.NET process identity, see Configuring ASP.NET Process Identity[^] and ASP.NET Impersonation[^].

Source: Session-State Modes | Microsoft Docs[^]

For further details, please see:
ASP.NET Session State Overview | Microsoft Docs[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900