views:

20

answers:

2

I need to send data before making a "RedirectToAction" to the new view, and do not want the data being sent by "GET".

The only thing I can think of is to keep this information in session before redirecting to the new view, but I prefer to do otherwise.

Thanks.

Edit width example

public class AccountController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult Login()
    {
        return View(new LoginViewModel());
    }

    [HttpPost]
    public ActionResult Login(LoginViewModel model, string returnUrl)
    {
        if (LoginModel.Login(model)){

             UserData ud = UserData(model.IdUser);
             return RedirectToAction("Index", "Information");

        }

        // code
     }
}     

//

public class InformationController : Controller
{
    public ActionResult Index()
    {

        //receives "ud" information
        // ... 
        return View();
    }

}     
A: 

I'm not sure what you are trying to achieve but TempData["yourkey"] might be what you want to use. it's not best practice though. but if you want to redirect to an action, where do you want the data to be sent to?

Stefanvds
+1  A: 

You could pass the data as a request parameter:

return RedirectToAction("Foo", new { param1 = "value1", param2 = "value2" });
Darin Dimitrov