tags:

views:

44

answers:

3

In ASP.NET/VB.NET 2005 I've created a small web app with two forms.

In Default there is a button and a text box and a link.

When you press the button whatever is in the text box is put into the Session.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    System.Web.HttpContext.Current.Session("mykey") = Me.TextBox1.Text
End Sub

When you press the link it's NavigateURL property is "~/Retrieve.aspx"

On the Retrieve page it pulls the information out of the Session (that is, whatever you typed in the text box).

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim myValue As String = CType(System.Web.HttpContext.Current.Session("mykey"), String)
    Response.Write(myValue)
End Sub

Now it works on my machine and when deployed to the production web-site server if I run the browser remotely there it works fine - What you type on the first page appears on the second page.

But when I run it from my machine to the production web server the second page is always blank.

Why?

It doesnt seem like a timeout issue - brand new web.config taking the defaults.

Any pointers would be greatly appreciated! Thanks!

A: 

Could it be a cookie issue on your local machine? Are you switching domain names or the application pool is recycling? Those would be my suggestions for a couple of starting points.

JB King
+3  A: 

So when you have the first page redirect from your machine to the production machine it doesn't work?

That's because the session is stored on the server itself, not in your browser. So your session exists on your machine but not on the server.

If you want it to persist across machines, then you would either need to use a cookie (which is stored in your browser) or have some kind of shared state server that uses a shared database to store session data.

Eric Petroelje
@Eric Petroelje is very right. Sessions are local to a machine (except for webfarms and SQL session state). The cookie that is used by sessions is just so that the local server has a key to retrieve session state.
Chris Haas
I'd have never thought that *this is really* what the OP tried. :)+1 for cutting the knot the simplest way. :)
andras
A: 

I dont see how, but I dont know how I could test for that either?

Michael Taylor