I have an ASP.NET MVC application that is published on two IIS servers (approval and production);
In this application, I use the Session variable to save the user's login to a part of it, however, on the production server the creation of the Session variable is not working, returning me the error: object reference not set to an instance of an object
I think there might be some configuration in IIS because the same code works on the rationing server and also on localhost, so I can not debug.
I have never done a configuration in IIS, but when I briefly studied it, I found that there is a configuration for Session State, as shown below, but by default, it is already set to True and even changing to False, the same error continues.
Following line of code for analysis:
// POST: Auth/Login/{login}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(DTOViewModel login)
{
try
{
this.Autenticar(login.Usuario, login.Senha);
Session["user"] = login.Usuario; // <---- aqui que está dando problema
return Json(new { url = Url.Action("Index", "Usuario/Home") });
}
catch (Exception ex)
{
return Json(new { erro = ex.Message });
}
}
Follow IIS configuration image:
Thanks to anyone who can help. :)