Asp.net mvc ASP.NET MVC:路由时如何获取Request.QueryString值
假设我有以下规则Asp.net mvc ASP.NET MVC:路由时如何获取Request.QueryString值,asp.net-mvc,Asp.net Mvc,假设我有以下规则 routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
在控制器中
public ActionResult Forums(int id)
{
Response.Write(id); // works
Response.Write(Request.QueryString["id"]); // doesn't
return View();
}
如何使用Request.QueryString获取它?我认为您需要通过访问路由参数 例如
我认为您需要通过访问路由参数 例如
非常感谢你!这正是我想要的。你无法想象这对构建多租户应用程序有多重要。再次感谢,非常感谢!这正是我想要的。你无法想象这对构建多租户应用程序有多重要。再次感谢。
Routedata.Values["id"]