【发布时间】:2012-09-20 18:10:30
【问题描述】:
ASP.NET MVC 4 网站。
有一个名为“Locations”的数据库表,其中仅包含三个可能的位置(例如“CA”、“NY”、“AT”) 默认路由是:
http://server/Location/ --- list of Locations
http://server/Location/NY --- details of NY-Location
如何在没有 /Location/ - 位的情况下创建自定义路线? (我觉得更好一点)
这样
http://server/NY - details of NY
http://server/AT - details of AT
.... etc...
和
http://server/Location --- list of Locations
【问题讨论】:
-
在控制器中设置?在控制器内部,您必须指定路线,然后指定它附带的功能,对吗?所以将路由设置为
server/{city}
标签: asp.net-mvc-4 asp.net-mvc-routing