ini*_*lin 80 asp.net asp.net-mvc fragment-identifier
我有以下问题:例如我有这样的路线:
routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler())
Defaults = new RouteValueDictionary(
new { controller = "Thread", action ="ShowThreadLastPostPage"}),
Constraints = new RouteValueDictionary(new { threadOid = @"^\d+$" })
}
);
Run Code Online (Sandbox Code Playgroud)
有没有办法使用RedirectToAction方法导航到这样的URL:
forums/thread/{threadOid}/last#postOid
Meh*_*ari 149
我认为你应该使用这个Redirect
方法Url.RouteUrl
来实现它.
return Redirect(Url.RouteUrl(new { controller = "Thread", action = "ShowThreadLastPostPage", threadOid = threadId }) + "#" + postOid);
Run Code Online (Sandbox Code Playgroud)
Jo *_*Smo 17
另一种选择Url.Action
:
return Redirect(Url.Action("ShowThreadLastPostPage", "Thread", new { threadOid = threadOid }) + "last#" + postOid);
Run Code Online (Sandbox Code Playgroud)