views:

456

answers:

2

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.

+3  A: 

Use tempData http://stackoverflow.com/questions/1936/how-to-redirecttoaction-in-asp-net-mvc-without-losing-request-data

Tadeusz Wójcik
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
ooo
A: 

Hello ooo,

I was wondering if you could figure out a neat way (not using TempData) of passing data from one controller to another? I am in the same boat...

Alex