Sharing sessions across applications using the ASP.NET Session State Service

后端 未结 3 1674
深忆病人
深忆病人 2020-11-22 12:05

I am trying to share sessions between two web applications, both hosted on the same server. One is a .net 2.0 web forms application the other is as .net 3.5 MVC2 application

3条回答
  •  失恋的感觉
    2020-11-22 12:48

    The problem is that session keys are scoped to the applications, so two applications having the same session key in fact have separate sessions.

    You can do one of two things:

    1. Put both applications as a virtual directory under a common IIS Application. I don't think this is a good idea, but it will work.

    2. Roll your own session data solution for the data you want to share. Possibly using the backend database as the common storage, if you have one that is.

    Based on Justin's comment, just to clarify option 2 is not refering to the SQL state managemet for out of process sessions. I mean for you to actually manually manage the shared data for the two sessions, possibly using a database.

提交回复
热议问题