2 asp.net url asp.net-mvc url-routing
我希望它能做出类似这样的东西=> http:// localhost:4330/Restaurants/Manchester /?Cuisine = Chinese&MaxPrice = 120000
其中没有值(0)的Param Query字符串将不包含在查询字符串URL中是否可能?
更新
string将此添加到Global.asax路由
routes.MapRoute(
"Name of route", // Route name
"Restaurants/{cityid}/", // URL with parameters
new { controller = "Restaurants", action = "Index" } // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)
这是控制器:
public ActionResult Index(string city, int cuisine = 0, int ChineseMaxPrice=0)
{
Return View();
}
Run Code Online (Sandbox Code Playgroud)
就像int cuisine = 0 - 如果未在querystring中设置此参数,则将默认值设置为parameter
string city - 是一个应该在字符串中的参数(不是可选的)
归档时间: |
|
查看次数: |
1139 次 |
最近记录: |