【发布时间】:2015-05-02 07:06:16
【问题描述】:
我无法在 MVC 中获取 UrlParameter 的值。我认为除了 1 件事之外,一切都设置正确。
这是我的地图路线
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Banyo", // name it!
"{controller}/{action}/{Filtre}", // Route name
new { controller = "Banyo", action = "Marka", Filtre = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Home", // Route name
"{action}/{Filtre}", // URL with parameters
new { controller = "Home", action = "Index", Filtre = UrlParameter.Optional }
);
}
这里是动作函数...
public ActionResult Marka(string Filtre = null)
{
return View();
}
即使我输入 url "http://localhost:7555/Banyo/Marka/Seranit" ,并且 Filtre 总是返回 null 。我期待得到“Seranit”值 Filtre 参数。
如果我输入“localhost:7555/Banyo/Marka?Filtre=Seranit”; ...过滤参数给了我预期的值“Seranit”。我该如何解决这个问题?
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-routing