ASP.NET MVC Routing URL QueryString
Is there a way to link to another view that displays search results without having to use a query? For example, I know I can do the following:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(string txtOrderNumber)
{
return RedirectToAction("OrderLookup", new { controller = "Report", id = txtOrderNumber });
}
But let's say that I want to use a hyperlink (hyperlink with an order number) and not a form post. How can I redirect to the View result without using a query? many thanks.
source to share
Eric,
With webforms, the command argument is passed by creating a message and the value is stored in the control (I believe it is stored in a hidden field, or in the view, which is also a hidden field), but the page posts back.
If you don't want to post and don't use a request, the only solution I can think of is to post the post on the same page, grab the ID, store it in TempData, and then do RedirectToAction. In the controller, just use the TempData value saved in the previous page.
This still generates a message, but if the user refreshes the page, they will not see the Send Data message.
source to share