我有以下问题: 例如我有这样的路线:
routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler())
Defaults = new RouteValueDictionary(
new { controller = "Thread", action ="ShowThreadLastPostPage"}),
Constraints = new RouteValueDictionary(new { threadOid = @"^\d+$" })
}
);
有没有办法使用 RedirectToAction 方法导航到这样的 URL:
forums/thread/{threadOid}/last#postOid
最佳答案
我认为您应该使用 Redirect
方法和 Url.RouteUrl
来完成它。
return Redirect(Url.RouteUrl(new { controller = "Thread", action = "ShowThreadLastPostPage", threadOid = threadId }) + "#" + postOid);
关于带 anchor 的 ASP.Net MVC RedirectToAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/602788/