0
假設我有一個隨機接受用戶的網站。規則很簡單;隨機生成器可以告訴用戶可以登錄或不登錄。使用新的OWIN標識API登錄
那麼應該如何使用這段代碼呢?
private async Task SignInAsync(ApplicationUser user, bool isPersistent)
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
HttpContext.GetOwinContext().SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
}
我沒有ApplicationUser,我沒有注入DbContext,我沒有用戶(!)表。
主要問題;我的簡單身份驗證在哪裏?
FormsAuthentication.RedirectFromLoginPage ("I_am_a_User", Persist.Checked)