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.

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.