私はASP.NET MVC 1.0でAppを作成し、カスタムメソッド(管理者用)を使用してユーザーを作成したいと考えています。私はAccountメソッドのRegisterメソッドを使ってCreateメソッドに名前を変更しました。私はその後、行をコメントアウトしましたFormsAuth.SignIn(userName、false);新しく作成されたユーザーがサインインするのを避けるためMembershipService.CreateUser()をASP.NET MVCの自動ログインから停止する方法はありますか?
ユーザー作成フォームを完了すると、ユーザーはうまく追加されますが、サインインします。これで私と新しいユーザーがサインインされました。なぜならuser.IsOnlineのための私のListUsersのページのテスト
UPDATE(2009-07-15 14:40):私はいくつかのGoogleの-INGをやってuser.IsOnlineが原因ステートレスHTTPに非常に信頼性がないことが判明していますプロトコル。注:UserDetailsページ(MembershipUserAndRolesViewDataを使用して作成された)に移動した場合、Last LoginはNULLとして表示されます。しかし、私のListUsersページにはログイン日が表示されます... ???
public class AccountController : Controller
{
// ...
[Authorize(Roles = "Administrator")]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(string userName, string email, string password, string confirmPassword)
{
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
if (ValidateRegistration(userName, email, password, confirmPassword))
{
// Attempt to register the user
MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);
if (createStatus == MembershipCreateStatus.Success)
{
//FormsAuth.SignIn(userName, false); // createPersistentCookie
return RedirectToAction("ListUsers", "Account");
}
else
{
ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
}
}
// If we got this far, something failed, redisplay form
return View();
}
}