我正试图了解MVC3附带的路由。我正在使用Razor对我的网站进行编码。我想知道在基于动态路由的方法中设置以下场景的最佳实践是什么。
目前我的网站结构设置如下(CAPS是文件夹):
- Default.cshtml
- About.cshtml
- Contact.cshtml
- Services.cshtml
- CONTENT
- ABOUT
- aboutus.cshtml
- history.cshtml
- CONTACT
- contact1.cshtml
- contact2.cshtml
- SERVICES
- service-web.cshtml
- service-mobile.cshtml
- all.cshtml
- VIEWS
- CONTROLLERS
- MODELS
当前URL显示如下:
www.website.com/content/about/aboutus.cshtml
www.website.com/content/contact/contact2.cshtml
www.website.com/content/services/all.cshtml
所以我更喜欢我的网址看起来像这样:
www.website.com/about/aboutus
www.website.com/contact/contact2
www.website.com/services/all
那么,以一切神圣的名义,这怎么可能呢?我已经在这里找了很长一段时间了,我发现的一切都与基于日期或ID的URL有关,而不是像我的网站那样的文件夹。
非常感谢您的帮助,谢谢!
我认为您需要了解更多关于MVC 3的信息:http://weblogs.asp.net/scottgu/archive/2011/03/09/free-video-training-asp-net-mvc-3-features.aspx