Mark
Mark

Reputation: 21

ASP.NET MVC 2 - How do I pass a querystring back on response?

I need to pass a querystring back on response - so that via means of jQuery I can do something with it.

something like this: return RedirectToAction("LogOn", "Account", new { id = "?action=update" });

URL needs to end up like: ../Account/LogOn/?action=update

but the above code produces this instead: ../Account/LogOn/%3faction%3dupdate

I don't want the encoding...

Help?

Upvotes: 0

Views: 974

Answers (2)

Langeleppel
Langeleppel

Reputation: 238

In your controller, name the parameter with the @ sign, as Pawel writes. So

public ActionResult YourAction(string @action)  will work
public ActionResult YourAction(string action)  will fail

Upvotes: 0

Buildstarted
Buildstarted

Reputation: 26689

I think, in this case, you should use

return RedirectToAction("About", "Home", new { sendto = "update" });

You can't use the keyword "action" because it will be consumed by mvc, so I've replaced it with "sendto" instead.

Upvotes: 3

Related Questions