MVC 5 Forms Authentication Validates Null for User.Identity.Name

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.RedirectFromLoginPage(userID, user.RememberMe);
                                FormsAuthentication.SetAuthCookie(userID.ToString(),true);

                                FormsAuthentication.RedirectFromLoginPage(userID, false); //DO NOT REMEMBER ME

}

HomeController (default page)

 public ActionResult Index()
        {

            bool x = User.Identity.IsAuthenticated; //false?
            string y = User.Identity.Name; //null?

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"/>
+4
1

Owin , . -,

<remove name="FormsAuthentication" />

.

.

, .

+5

All Articles