Simple session code not working - Help!

  • Thread starter Hema S via DotNetMonster.com
  • Start date
H

Hema S via DotNetMonster.com

Hi,

I am too facing the same problem and need the solution asap. can anyone
help out.

Thanks in advance.

Hema S
 
C

Chris R. Timmons

As I understand it the point of the state server method is to
enable different processes to share session info...

As long as those different processes are all the same web app.

StateServer (and SqlServer) applies to a web farm configuration (i.e.
the same web app running on multiple machines).

For example, the same web app may be running on two different
machines. The web app's config file on both machines have their
<sessionState> element set to use a StateServer on machine #1.

A user's first page request may be handled by machine #1, and session
data is created and stored on that machine. The user's second page
request might be handled by machine #2, and that machine will simply
access the session data on machine #1.

Other web apps, regardless of where they are running, cannot access a
different web app's session data.
 
H

Hema S via DotNetMonster.com

Hi,

My application is like i have a Main application and Sub Modules - each as
seperate application called by the Main Application.
Sub Modules share some menu from Main Application.
When i work on sub moduels and switch back to Main , the session time in
main modules expires and its redirecting to login page, which is not
correct, can u suggest me to prevent the session timeout problem when i
switch from sub moduels to main modules and viceversa.

Hema S
 
L

Logickle

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
 
J

Juan T. Llibre

What you describe looks like a single application that
you have unnecessarily broken into two different parts.

Basically, you should not run your modules as separate
applications, but as subdirectories of your main application.

You need to review, carefully, the process described
in this KB, to see if you are setting up your project
in a way which will allow sharing session information :

http://support.microsoft.com/default.aspx?scid=kb;en-us;307467

Alternately, you might want to consider not using the built-in session
and application objects and, instead, writing your own classes and
exposing the properties you need, serializing to/from XML,
as Samuel Matzen suggests :

http://searchvb.techtarget.com/vsnetATEAnswers/0,293820,sid8_gci1011277_tax293672,00.html
 
B

Bruce Barker

this is the way asp.net is designed - session is not shared between vdir.
this is implemented by specifing the vdir path when storing the session
cookie. you just need to override session cookie store to only use the
server name (use an httpmodule for this).

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top