我要接受
[HttpGet]
[Route("{forumName}", Order = 8)]
[Route("{forumName}/Page/{page}", Order = 7)]
[OutputCache(Duration = 30, VaryByParam = "forumName;page", Location = OutputCacheLocation.ServerAndClient)]
public async Task<ActionResult> ShowForum(string forumName, int page = 1)
和
[HttpGet]
[RefreshDetectFilter]
[Block(VisibleBlock = false)]
[Route("~/Forums/{forum}/{topicName}", Order = 6)]
[Route("~/Forums/{forum}/{topicName}/Page/{page}", Order = 5)]
[OutputCache(Duration = 30, VaryByParam = "topicName;page", Location = OutputCacheLocation.ServerAndClient)]
public async Task<ActionResult> ShowTopic(string forum, string topicName, int page = 1)
剃刀
<a href="@Url.Action("ShowForum", "Forums", new {forumName = Model.NameTranslit})" title="@Model.Name">@Model.Name</a>
和
<a href="@Url.Action("ShowTopic", "Forums", new { forum = Model.CurrentForumTranslite, topicName = Model.TitleTranslite })" title="@Model.Title">@Model.Title</a>
当我在页面上用这个例子
/论坛/测试/页/ 2
链接到子论坛我有正常的链接,但链接到我有页面的主题
/论坛/测试/ Test_Topic /页/ 2
但应该是
/论坛/测试/ Test_Topic
我的理解。我有这个错误,因为在我的操作中,我有相同的页面路径参数
我该怎么做才能解决这个问题?
答案 0 :(得分:0)
我找到了解决问题的方法
对于路线ShowTopic
<a href="@Url.RouteUrl("showTopic", new { forum = Model.CurrentForumTranslite, topicName = Model.TitleTranslite })" title="@Model.Title">@Model.Title</a>
我添加了名字
Math
对于获取主题的网址,我正在使用Url.RouteUrl
Math.hypot(3, 4)