0

I have gone through this link and am facing the same problem, which is not resolved.

So here is the simple thing,I have the below code:

return View("ResetPassword", resetPasswordModel);

Now, along with model, I want to pass a query string which should get appended in the URL. Is there any way to pass the model as well as query string in the same call?Please remember, I m gonna redirect to this view, not to another action method.(So RedirectToAction won't work!)

Thanks in advance.

Community
  • 1
  • 1
user2948533
  • 1,143
  • 3
  • 13
  • 32
  • In order to change the url, you need to redirect (and you redirect back to the same view using `RedirectToAction("ResetPassword", new { .... })` –  Feb 26 '16 at 21:53

1 Answers1

-1

You can use Viewbag to send any type of data to the view from controller like this:

ViewBag.QueryString = "Your query string";

Here, you can write any good name instead of QueryString.

The way you get it in the view is like this:

@ViewBag.QueryString

See this MSDN post https://msdn.microsoft.com/en-us/library/system.web.mvc.controllerbase.viewbag(v=vs.118).aspx

Nabin
  • 163
  • 1
  • 12
  • Nab, I know how to store and retrieve the value using Viewbag, but I want the query string values to be appended in the actual URL when the View is being generated! – user2948533 Feb 29 '16 at 14:04
  • to achieve this, i would call another action from the first action and pass those data in the query string and call the view from that 2nd action action. – Nabin Feb 29 '16 at 23:00