Let's say I have the following rule
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
And in the controller
public ActionResult Forums(int id)
{
Response.Write(id); // works
Response.Write(Request.QueryString["id"]); // doesn't
return View();
}
How can I get it with Request.QueryString?
I think you need to go through RouteData to access the routing parameters.
Eg
Routedata.Values["id"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.