title: Can't create Session in Asp MVC
body: <p>I have an ASP.NET MVC Application which is published on 2 IIS web servers (one for <code>debug</code> and one for <code>release</code>).</p>
  
  <p>In this application, I use a Session variable to keep the user Login, but in the <code>release</code> server this Session definition didn't work, returning the error: </p>
  
  <blockquote>
    <p>object reference not set to an instance of an object</p>
  </blockquote>
  
  <p>I believe that it can only be IIS configurations, because the same code works fine on the <code>debug</code> server and in localhost, that is why I can not debug the application.</p>
  
  <p>I have never made a IIS configuration before, but in my search about it, I found that there is a config for the Sessions State (see this link <a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc754450(v=ws.10)" rel="nofollow noreferrer">here</a>), which, for default, is set as <code>true</code>, and if I try to set <code>false</code>, nothing different happens.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>// POST: Auth/Login/{login}
  [HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult Login(DTOViewModel login)
  {
      try
      {
          this.Autenticar(login.Usuario, login.Password);
          Session["user"] = login.Usuario; // &lt;---- Here is the problem
          return Json(new { url = Url.Action("Index", "User/Home") });
      }
      catch (Exception ex)
      {
          return Json(new { erro = ex.Message });
      }
  }
  </code></pre>