Asp.Net メンバーシップでカスタム CreateUser を作成しました。今私が欲しいのは、ユーザーが作成されたときに、default.aspxページでloggedInユーザーとしてリダイレクトする必要があることです。認証してデフォルト ページにリダイレクトする方法を教えてください。彼に再度ログインしてほしくありませんが、ユーザーが正常に作成されると、自動的にログインしてデフォルトページに移動する必要があります。
これが私のコードです。
public string AddUser(string UserName, string FirstName, string LastName, string Gender, string EmailID, string Password, string Mobile, string SecurityQuestion, string SecurityAnswer)
{
MembershipCreateStatus CreateStatus;
MembershipUser newUser = Membership.CreateUser(UserName, Password, EmailID, SecurityQuestion, SecurityAnswer, true, out CreateStatus);
if (CreateStatus == MembershipCreateStatus.Success)
{
Guid newUserId = (Guid)newUser.ProviderUserKey;
if (RegisterCustomFields(newUserId, FirstName, LastName, Gender, Mobile) != 0)
{
Roles.AddUserToRole(newUser.UserName, "User");
ReturnMsg = "Successfully Created ";
}
else
{
Membership.DeleteUser(newUser.UserName);
ReturnMsg = "Error Creating User";
}
}
else
{
switch (CreateStatus)
{
case MembershipCreateStatus.DuplicateUserName:
ReturnMsg = "There already exists a user with this username.";
break;
case MembershipCreateStatus.DuplicateEmail:
ReturnMsg = "There already exists a user with this email address.";
break;
case MembershipCreateStatus.InvalidEmail:
ReturnMsg = "There email address you provided in invalid.";
break;
case MembershipCreateStatus.InvalidAnswer:
ReturnMsg = "There security answer was invalid.";
break;
case MembershipCreateStatus.InvalidPassword:
ReturnMsg = "The password you provided is invalid. It must be seven characters long and have at least one non-alphanumeric character.";
break;
default:
ReturnMsg = "There was an unknown error; the user account was NOT created.";
break;
}
}
return ReturnMsg;
}