如何使用查询字符串更改路由URL

时间:2018-06-02 07:13:56

标签: url routes maproute routeconfig

我有一个动作如下

 public ActionResult searchresult(int Race, string province, string City)
 {
    var q = (................ my query.......)
    return View(q);
 }

并在RouteConfig中:

routes.MapRoute(
name: "searchresult",
url: "Home/searchresult/{Race}/{Province}/{City}",
defaults: new { controller = "Home", action = "searchresult" }
   );

但在网址中我得到http://localhost:2140/Home/searchresult?Race=3&Province=tehranCity=tehran

为什么它不会显示为http://localhost:2140/Home/searchresult/3/tehran/tehran

0 个答案:

没有答案