I have 2 Index Actions Post And Get when I submitted form the Post Action returned:
return RedirectToAction("Index");
Edit:
My get Index Action can get some parameters to support search and filter returned List. like this:
public ActionResult Index(string search = "", long searchItem = 0, long RC = 0, long Page = 1)
I used Paged List and there is a DropDownList that show Numbers of row in per page, I Write a jquery script to change of this dropdown form.submited and when form submitted
in RedirectTAction I lost my parameters the followings Code:
[HttpPost]
public ActionResult Index(FormCollection collection, string search = "") {
long RowCount = 0;
long.TryParse(string.Format("{0}", collection["RowCount"]), out RowCount);
//More implement
return RedirectToAction("Index", new { RC = RowCount, search = search, searchItem = Id });
So is there any way to Get Url or url parameters in Post Action? What is your suggestion in situations like this?
You could capture all query string parameters in a RouteValueDictionary before redirecting:
This will only keep the query string parameters. If you want to add route values and POSTed values you could concatenate them to the result.