Why would the value of the Session object go away?

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-04-09T19:45:57Z Indexed on 2010/04/09 19:53 UTC
Read the original article Hit count: 301

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about ASP.NET