2

ユーザーがメンバーシップを作成した後(アカウントを作成した後)、ログイン後、次のhttprequestの前に、ユーザープロファイルに値を割り当てようとしています

ただし、プロファイル値を割り当てる前にユーザーのサインイン/認証を試みますが、ユーザーは次の httprequest まで認証されません。

これは私のコードがどのように見えるかです:

    [HttpPost]
    public ActionResult Register(RegisterModel model)
    {
        if (ModelState.IsValid)
        {
            // Attempt to register the user
            MembershipCreateStatus createStatus = UserService.CreateUser(model.Email, model.Password);

            if (createStatus == MembershipCreateStatus.Success)
            {
                //Adding role
                UserService.AddDefaultRole(model.Email);

                FormsService.SignIn(model.Email, false); //Inside: FormsAuthentication.SetAuthCookie(email, createPersistentCookie);


                HttpContext.Current.Profile["FistName"] = firstName; //WON'T WORK - USER ISN'T AUTHENTICATED YET
                HttpContext.Current.Profile["LastName"] = lastName; // WON'T WORK

                return RedirectToAction("List", new { area = "Requests", controller = "Requests" }); //User will only be authenticated after this this redirection
             }

匿名ユーザーを有効にし、プロファイル値を割り当て、後で次の httprequest (ユーザーが認証されたとき) の後、このデータを認証されたユーザーに渡すことを考えています。

とにかくそれを行うことはありますか?もしそうなら、それを行うためのチュートリアルはありますか? そうでない場合、この問題にどのようにアプローチすればよいですか?

4

1 に答える 1

0

これらの値をCookieに入れてみませんか。アカウントの作成時に、Cookieを読み取り、プロファイルを更新してから、登録者が最終的に必要な場所に再度リダイレクトするアクションにリダイレクトします。

于 2011-09-10T20:20:48.163 に答える