How to share SQL Session with 2 websites on same server RRS feed

  • Question

  • User1773951238 posted

    I've been working on trying to get a blue/green deployment architecture setup on a windows 2016 server. But just ran into a brick wall because since these 2 web farm "servers" are actually not separate servers, but reside on the same server, they can't have the same path.

    From: https://docs.microsoft.com/en-us/previous-versions/aspnet/ms178586(v=vs.100)

    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. For information on steps to resolve the issue when application paths differ between servers, see article 325056, "PRB: Session State Is Lost in Web Farm If You Use SqlServer or StateServer Session Mode," in the Microsoft Knowledge Base at http://support.microsoft.com.

    And from: https://mskb.pkisolutions.com/kb/325056

    To maintain session state across different Web servers in the Web farm, the application path of the Web site (for example, \LM\W3SVC\2) in the Microsoft Internet Information Services (IIS) metabase must be the same for all of the Web servers in the Web farm. The case also needs to be the same because the application path is case-sensitive.

    So is there any work around to running SQL Server Session State when not using the same website path as both websites in the farm are on the same server and hence can't share the same path name?

    Tuesday, September 22, 2020 4:10 PM

All replies

  • User753101303 posted


    You could likely update the stored procedures used by this provider and update them so that they share the same application id (make sure to use thios db only for those two apps).

    Another option could be to try to find the code at https://github.com/aspnet/AspNetWebStack or maybe https://referencesource.microsoft.com/ (gave a quick look but didn't found yet).
    With a bit of luck you might be able to inherit from this session state provider and change the part that is retrieving the application id.

    Not directly related but I try to store in session something that can be reloaded on demand (possibly from the db). This way it should work with any session provider even inproc.

    Tuesday, September 22, 2020 5:10 PM