开发者

ASP.Net Session variables - struggling with the Cache

开发者 https://www.devze.com 2023-03-17 00:32 出处:网络
I\'m using some session variables to store and pass data across several pages of an ASP.Net application. The behavior is a bit unpredictable though. I\'m setting the session variable post page_load as

I'm using some session variables to store and pass data across several pages of an ASP.Net application. The behavior is a bit unpredictable though. I'm setting the session variable post page_load as follows

Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
If (Session.Item("ScholarshipID") = Nothing) Then
    Session.Add("ScholarshipID", "Summer2011")
End If

Ok so far so good, on a normal page load. If the user completes the form action, hits the next page, and decides OH NO, i needed to change field xyz, and clicks back, corrects t开发者_如何学Che data, then submits, the session variable is showing as NULL. Why would a cached session behave this way? I'm not destroying/clearing the variable, unless I fail to understand the scope of session variables.


try

If (IsNothing(Session("Scholarship"))) Then
     Session("Scholarship") = "Summer2011"
End If
0

精彩评论

暂无评论...
验证码 换一张
取 消