Asp.net mvc Forms Authentication 防止用户在创建时自动登录
Asp.net mvc Forms Authentication Prevent user from been automatically logged when created
Asp.net mvc 4 应用程序,使用 Forms 身份验证,我有一个管理员角色,可以将用户添加到应用程序,但是当我创建一个新用户时,它会自动登录新创建的用户,我该如何防止这个?
这是我在帐户控制器中的注册操作
[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);
}
Asp.net mvc 4 应用程序,使用 Forms 身份验证,我有一个管理员角色,可以将用户添加到应用程序,但是当我创建一个新用户时,它会自动登录新创建的用户,我该如何防止这个?
这是我在帐户控制器中的注册操作
[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);
}