public ActionResult Product(int id) { var routeValues = GetRouteValueDictionary(); // routeValues now contains the values of controller, action, and id // e.g. { "controller" = "Home", "action" = "Product", "id" = id } // code to retrieve product details using the id parameter // ... return View(product); }
public ActionResult Home() { var routeValues = new RouteValueDictionary { { "category", "books" }, { "page", 2 } }; var url = Url.Action("Index", "Catalog", routeValues); // url will be "/Catalog/Index?category=books&page=2" return Redirect(url); }Package library: Microsoft.AspNet.Mvc.