开发者

Passing profile data from anonymous user to logged in user

I'm trying to assign some value to user profile after a user create a membership (create an account), after logging in but before the next httprequest

Although, I try to sign-in/authenticate user before assigning profile values, user won't be authenticated until the next httprequest.

This is what my code looks like:

    [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"] = first开发者_JS百科Name; //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
             }

I'm thinking to enable anonymous user, assign the profile values, and later after the next httprequest (when the user is authenticated) pass this data to the user that has been authenticated.

Is there anyway to do that? If so, is there any tutorial for doing that? if not, how should I approach this problem?


Why not put these values in a cookie, on account creation redirect to an Action that reads the cookie and updates the profile and then redirects again to wherever you want the registrant to end up?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜