Authentication does not authenticate to authenticate forms in my MVC 5 application. The page is being redirected correctly, but the values of User.Identity.IsAuthenticated and User.Identity.Name are empty.
My webconfig,
<system.web>
<authentication mode="Forms">
<forms cookieless="UseCookies" defaultUrl="~/" loginUrl="~/user/signin" name="MYAPPWeb" timeout="21600" slidingExpiration="true"/>
</authentication>
UserController
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult SignIn(SignInViewModel user)
{
UserDTO userObj;
using (var services = new ServiceFactory())
{
userObj = services.UserManagement.ValidateLoginDetails(ConfigHelper.EnvironmentString, user.TenantName, user.Username, user.Password);
}
string userID = userObj.UserID.ToString();
FormsAuthentication.SetAuthCookie(userID.ToString(),true);
FormsAuthentication.RedirectFromLoginPage(userID, false);
}
HomeController (default page)
public ActionResult Index()
{
bool x = User.Identity.IsAuthenticated;
string y = User.Identity.Name;
return View();
}
It looks pretty straight forward, am I missing something? Please, help!
Note:
When I create the project, I selected Windows Authentication. He created some configuration cs files related to Owin authenticaiton (startup.auth.cs). I deleted them and added the above appsetting entry, since I want to stop loading Owin collectors.
<add key="owin:AutomaticAppStartup" value="false"/>