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.

1
  • In order to change the url, you need to redirect (and you redirect back to the same view using RedirectToAction("ResetPassword", new { .... }) Commented Feb 26, 2016 at 21:53

1 Answer 1

-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

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

2 Comments

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!
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.

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.