有可选参数
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
我要让我的网址,以便在一开始就进入公司的名称,例如:
url: "{company}/{controller}/{action}/{id}"
这样我就可以通过网页浏览和现在该基地是一些公司。
- domain.com/company-ltd
- domain.com/company-ltd/products
- domain.com/company-ltd/edit
- domain.com/some-other-company- name-ltd/products
等等。
我怎么能做到这一点?谢谢。
不,不好意思,你在开始时不能有可选的路由参数。只有路线中的最后一个参数可以是可选的。 –