title: Session variables not propagating
body: <p>I have set up a standard ASP.NET Webforms application on my PC. The login pages stores 3 session variables; a username, password and redirect. </p>
  
  <p>From what I've seen, I can use <code>Session["user"] = username</code> or <code>Session.Add("user", username);</code> to set the variables.</p>
  
  <p>Once the variables have been set, I redirect to another page which performs some further authentication checks.</p>
  
  <p>In the receiving page, I have the following</p>
  
  <pre><code>protected void Page_Load(object s, EventArgs e)
  {
     if (!IsPostBack)
     {
        var user = (string)(Session["user"]);
     } 
  }
  </code></pre>
  
  <p>When I come to look at user though, it is null.</p>
  
  <p>Everything on my set up are the out of the box values.</p>
  
  <p>Further info</p>
  
  <p>In my caller, the session is set like this</p>
  
  <pre><code> if (user.UserName == "admin")
   {
       Session.Add("user", UserName.Text);
       Session.Add("pass", Password.Text);
       Session.Add("redir", Request.QueryString["ReturnUrl"]);
       Response.Redirect("SecondPage.aspx", false);
   }
  </code></pre>
  
  <p>In my SecondPage.aspx</p>
  
  <pre><code>    if (!IsPostBack)
      {
          ReturnUrl = (string)(Session["redir"]);
          Username = (string)(Session["user"]);
          Password = (string)(Session["pass"]);
      }
  </code></pre>
  
  <p>(ReturnUrl, Username and Password are just simple get;set properties)</p>
  
  <p>** Additional</p>
  
  <p>Just to make sure I'm not losing my marbles, I've performed two additional tests.</p>
  
  <p>First I added in to the Page_Load for the first page the following</p>
  
  <pre><code>Session["fish"]="chips";
  </code></pre>
  
  <p>I then read that back in within Page2 and "chips" shows.</p>
  
  <p>Next I created a static class and assigned the properties of the class and tried to read that in within Page 2 - all of them were null despite them being set (and tested) before the redirect to page2.</p>
  
  <p>This has got me perplexed!</p>