Reputation: 31
I've recently moved an ASP.Net (3.5) application to a new server, and it has developed an odd issue that I'm having problems troubleshooting.
On each and every page load no matter what browser I'm using (IE, FF, Chrome) ASP.Net/IIS issues me a new Session on each page load, forgetting the previous session it called.
I have a simple page for testing this out as follows:
<asp:Button ID="Button1" Visible="true" runat="server" Text="Button" />
<%= HttpContext.Current.Session("Test")%>
<br /><br />
<%= Session("GlobalTest") %>
<a href="Test.aspx">Reload the page</a>
In the Code Behind I have this for the Button:
HttpContext.Current.Session("Test") = DateTime.Now.ToLongTimeString
In Global.asax
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
Session("GlobalTest") = "Session Created on : " + DateTime.Now.ToLongTimeString()
End Sub
When you push the button, it initially displays the Session value just fine. Go to reload the page, either via- the link, or just loading fresh and the information (except for the Global that now updates to a new time) goes away.
In web.config, the session is setup thus:
<sessionState mode="InProc" timeout="15" useHostingIdentity="false" cookieless="false" />
Has anyone experienced similar to this?
Upvotes: 2
Views: 2949
Reputation: 31
Okay, I figured it out. Thanks for all the suggestions.
Turns out what was going on was a lesser known tag to me, in the web config and I hadn't setup SSL Certs for that site yet. Remove that and works like a charm. Not slated to do that til next week.
This does create awkward behavior... It won't set a cookie for anyone ever, but you can use Session per normal and it will work properly for the first load when it then resets the cookie session (and you aren't over SSL).
Thanks again everyone.
Upvotes: 1
Reputation: 1949
Be sure you are not writing to bin directory, beause that will reset Application and Session variables each time it is written to.
Upvotes: 0