2009-03-02 61 views
77

我有以下问题: 例如,我有这样的路线:ASP.Net MVC RedirectToAction锚

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

回答

141

我想你应该一起使用Redirect方法来完成它。

return Redirect(Url.RouteUrl(new { controller = "Thread", action = "ShowThreadLastPostPage", threadOid = threadId }) + "#" + postOid); 
+0

非常感谢,它帮助! – inikulin 2009-03-02 15:58:05

14

另一种选择与Url.Action

return Redirect(Url.Action("ShowThreadLastPostPage", "Thread", new { threadOid = threadOid }) + "last#" + postOid);