title: Why is Request.Cookies null?
body: <p>This is a follow-up on another thread I have running which is <a href="https://stackoverflow.com/questions/11029643/reading-cookie-in-c-sharp">Reading cookie in c#</a> . However, the answers in that post seem to beat around the bush so I want to simplify my question here. I think that answering this, I'll be able to solve that problem. Stuck almost two days now trying to read a cookie so any help is appreciated.</p>
  
  <p>What could cause a NullReferenceException at this line:</p>
  
  <pre><code>HttpCookie aCookie = Request.Cookies["UserSettings"];
  </code></pre>
  
  <p>I am sure a cookie called "UserSettings" is there, as I can see it with developer toolbar.
  So Request or Request.Cookies must be null, right?</p>
  
  <p>Why can't I use Request.Cookies? Every single cookie tutorial I look at does it like that.</p>
  
  <p><strong>EDIT:</strong> added cookie creation code in index.aspx, btw im trying to read the cookie in HomeController.cs, dont know if this matters, but thought id mention it.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function setLanguage() {
      cname = "language";
      cvalue =           document.getElementById('language').options[document.getElementById('language').selectedInd    ex].value;
      cexpire = new Date();
      cexpire.addDays(1);
      document.cookie = cname + '=' + escape(cvalue) +
  (typeof cexpire == 'date' ? 'expires=' + cexpire.toGMTString() : '') +
  ',path=/;';
  }
  &lt;/script&gt;
  </code></pre>