[英]Asp.net mvc Forms Authentication Prevent user from been automatically logged when created
Asp.net mvc 4應用程序,具有窗體身份驗證,我具有將用戶添加到該應用程序的管理員角色,但是當我創建新用戶時,它將自動將新創建的用戶登錄,該如何防止呢?
這是我在帳戶控制器中的注冊操作
[HttpPost]
public ActionResult Register(string username, string password)
{
WebSecurity.CreateUserAndAccount(username, password);
Roles.AddUserToRole(username, "Mechanic");
FormsAuthentication.SetAuthCookie(username, false);
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
嘗試這個:
[HttpPost]
public ActionResult Register(string username, string password)
{
WebSecurity.CreateUserAndAccount(username, password);
Roles.AddUserToRole(username, "Mechanic");
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.