title: Session not working in ASP.Net
body: <p>I am new to ASP.Net and I can't seem grasp the working of my session. In some situations it works and in others not. Here you see the code where I create the session in one webform and call it in another form. In the Form_Load the second form can get data from the session but in the button_click event (page reload) the Session is "null". Can somebody help me?</p>
  
  <p>code Form 1:</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      Session["data"] = TextBox.Text;
      Response.Redirect("~/RapportFormulier2.aspx", false);
  }
  </code></pre>
  
  <p>code Form 2:</p>
  
  <pre><code>string s;
  protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          Logic logic = new Logic();
          logic.login(credentials);
          s = (string)(Session["data"]); // data is stored in the variable s
      }
  }
  
  protected void ButtonOk_Click(object sender, EventArgs e)
  {      
      string test = s; //null (normally because the reload)
      string s2 = (string)(Session["data"]); //null idk why
  }
  </code></pre>
  
  <p>I put the connection to my logic class in my postback since i have to re initiase it anyway.</p>
  
  <p>I am also open to some tips, since it is obvious i am struggling in ways.</p>
  
  <p>edit: I tried storing the first s in another session but even that i couldn't get back in the button_click...</p>
  
  <p>Form 2 load:</p>
  
  <pre><code>Session["data2"] = s;
  </code></pre>
  
  <p>Form 2 button_click:</p>
  
  <pre><code>string s2 = (string)(Session["data2"]); // null
  </code></pre>