Asp.net mvc 4 application, with Forms Authentication, I have a admin role who adds users to the application, but when I create a new user it automatically logs the new created user in, how can i prevent this?
here's my register action in the account controller
[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);
}
Try this:
[HttpPost]
public ActionResult Register(string username, string password)
{
WebSecurity.CreateUserAndAccount(username, password);
Roles.AddUserToRole(username, "Mechanic");
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.