- How to retrieve query string parameter in action.- By passing action argument as Query string parameter
public ActionResult Index(string urlparameter) { return Content("Your Url parameter is " + urlparameter); }
- By ID Parameter: ASP.NET MVC’s default routing convention is to treat the segment of a URL after the action method name as a parameter named ID. If your action method has a parameter named ID, then ASP.NET MVC automatically passes the URL segment to you as a parameter.
public ActionResult Product(string id1) { return Content("Your id is " + id1); }