Hi, all. I'm working on an application which requires communicating
session info between separate web apps running on the same web server.
The out of process server method sounded ideal, and very simple to
implement as far as I could tell. So I re-configured my apps'
web.config and machine.config files from InProc to StateServer, and
confirmed that's the mode used by both web apps.
To keep it simple, I created two basic ASP.NET apps Test1 and Test2,
and added enough code to (1) insert string session variables at session
start, and (2) read those variables at page load.
Also, in Test1 I added a button which redirects to Test2.
The problem is that the only session variable each can see is the one
*it* set. It doesn't see the variable set by the other - no error is
thrown, but reading the other's session variable returns an empty
string. As I understand it the point of the state server method is to
enable different processes to share session info, but even in this
simple code these processes can't see each others' data.
Any ideas what I'm doing wrong?? Thanks in advance!
Here's the specific code from my web apps:
Test1 -
========
Global.asx.vb:
--------------
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
Session("test1") = "test1"
End Sub
webform1.aspx.vb:
--------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Response.Write("Test1")
Response.Write("Session1: " & Session("test1"))
Response.Write("Session2: " & Session("test2"))
Response.Write("Mode: " & Session.Mode())
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Redirect("
http://localhost/Test2/WebForm1.aspx")
End Sub
Test2 -
========
Global.asx.vb:
--------------
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
Session("test2") = "test2"
End Sub
webform1.aspx.vb:
--------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Write("Test2")
Response.Write("Session1: " & Session("test1"))
Response.Write("Session2: " & Session("test2"))
Response.Write("Mode: " & Session.Mode())
End Sub