Bri*_*ard 5 rest seo url-routing asp.net-mvc-routing asp.net-mvc-4
我希望能够将我的 URL 重写为单级 URL。这意味着我需要制定一个动态的(将在每种语言中改变)重写规则,如下所示:
原始网址:http : //www.mydomain.com/account/pages/13
我总是想在单个级别中显示 URL:
http://www.mydomain.com/my-page-title
域名后不得超过一个斜杠 / 。
我还需要能够翻译上面示例中的页面标题:
http://www.mydomain.com/my-translated-page
我如何实现这一点,它应该能够在运行时改变这一点——即“改进”url,就像在 htaccess 中重写规则一样
您必须创建自己的Routes. 当您使用时,MVC4将此自定义路由放在应用程序的默认路由之上。
routes.MapRoute(
name: "Custom_Route",
url: "My-Page-Title/{id}",
defaults: new { controller = "Home", action = "About", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2472 次 |
| 最近记录: |