I'm developing a web site in ASP.NET MVC 2. At some point, I get to a ActionResult in a controller and I obviously call method
return View();
Is there any way, that I could pass QueryString into my view or attach parameters to the URL?
A view is supposed to manipulate the model which is passed by the controller. The query string parameters are already present when the request was made to the corresponding action. So to pass a view model:
var model = new MyViewModel
{
SomeParam = "Some value"
}
return View(model);
And now in your view you could use this model.
If on the other hand you don't want to return a view but redirect to some other controller action you could:
return RedirectToAction("SomeOtherActionName", new { ParamName = "ParamValue" });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With