Category "forms-authentication"

HttpContext.User NullReferenceException only on deployed server

I am using formsauthentication on my MVC project and when testing locally using the Visual Studio Development Server everything works as expected. Once deployed

HttpContext.User.Identity.IsAuthenticated throws System.NullReferenceException: Object reference not set to an instance of an object

My code is simple like : [HttpGet] public ActionResult Login () { if (User.Identity.IsAuthenticated) { return RedirectToAction("Index", "Home");