0

i have an AccountController that does the asp.net login and user registration. (Register action below.. After that is successful i also want to add this user data to another table of mind called users. Right now i have a "UsersController" and an action called "Create" so as you can see below i have the line:

return RedirectToAction("Create", "Users");

Here is the full registration method

[AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Register(string userName, string email, string password, string confirmPassword, string address, string address2, string city, string state, string homePhone, string cellPhone, string company)
    {
        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("Create", "Users");
            }
            else
            {
                ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
            }
        }

        // If we got this far, something failed, redisplay form
        return View();
    }

my issue is that i want to pass all of the arguments (userName, email, address, etc) into my action as these are fields in the users table as well

How do i pass arguments to this other action or is there some other recommended practices to do multiple actions at once and keep the state of the variables.

leora
  • 188,729
  • 360
  • 878
  • 1,366

1 Answers1

4

Use tempData How to RedirectToAction in ASP.NET MVC without losing request data

Community
  • 1
  • 1
T W
  • 6,267
  • 2
  • 26
  • 33
  • 1
    isn't there a cleaner way . . using tempdata seems a bit implicit as there is all this state hanging around in these dictionaries as opposed to being explicit arguments being passed from one method to another – leora Aug 06 '09 at 04:08