【发布时间】:2014-06-15 19:59:07
【问题描述】:
我在 asp.net mvc 4 中有网络,我设置了这样的路由
routes.MapRoute(
name: "CityByAlias",
url: "kaupunki/{alias}",
defaults: new { controller = "City", action = "DetailByAlias" },
namespaces: new string[] { "LepsiMisto.WebSite.Controllers" });
所以我可以使用 mysite.com/kaupunki/Kajaany 而不是 mysite.com/City/Detail/2816。
但是如果我像这样使用剃须刀
<a href="@Url.Action("Detail", "Announcement", new { id = announcement.ID })">
<h3>@announcement.Name</h3>
</a>
用户被重定向到 mysite.com/City/Detail/2816 我该如何设置这个,比如默认 URL mysite.com/kaupunki/Kajaany?如果用户将 mysite.com/City/Detail/2816 插入浏览器并将 Web 转换 url 插入 mysite.com/kaupunki/Kajaany,那将是最好的。
最好的方法是什么?
我为我的英语道歉,我知道这很糟糕。谢谢
【问题讨论】:
-
请参考stackoverflow的帖子stackoverflow.com/a/21455593/197878
标签: asp.net-mvc