Odd Behaviour RRS feed

  • Question

  • User-559653287 posted

    I am having odd behaviour with session state. If you create an empty web form, add a button (just to cause a postback), and the following code and run. When you click the button, the session("number") returns "5" as expected.

    However, create a blank master form, create an empty child web form, and add this SAME code with a button, run, and press the button, session is "nothing"

    am i missing something?

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Session("Number") = Nothing Then

         'If this page has a master, Session("number") always returns Nothing after the postback

         Session("Number") = 5


         'If this page has a master, Session("number") returns 5 after the postback

        'Session retained value

    End If

    End Sub 

    Friday, January 20, 2012 3:32 AM