ASP.Net MVC RedirectToAction锚 [英] ASP.Net MVC RedirectToAction with anchor
本文介绍了ASP.Net MVC RedirectToAction锚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下问题:
例如,我有这样的路线:
routes.Add(新干线(论坛/线程/ {} threadOid /最后一个新MvcRouteHandler())
默认值=新RouteValueDictionary(
新{控制器=线程,行动=ShowThreadLastPostPage})
约束=新RouteValueDictionary(新{threadOid = @^ \\ D + $})
}
);
有没有使用RedirectToAction方法浏览到这样的URL的方式:
论坛/线程/ {} threadOid /最后一个#postOid
块引用>解决方案我觉得你应该用
Url.RouteUrl <一起使用
重定向
方法/ code>来完成它。返回重定向(Url.RouteUrl(新{控制器=线程,行动=ShowThreadLastPostPage,threadOid =的threadId})+#+ postOid);
I have the following problem: For example I have route like this:
routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler()) Defaults = new RouteValueDictionary( new { controller = "Thread", action ="ShowThreadLastPostPage"}), Constraints = new RouteValueDictionary(new { threadOid = @"^\d+$" }) } );
Is there a way using RedirectToAction method navigate to the URL like this:
forums/thread/{threadOid}/last#postOid
解决方案I think you should use the
Redirect
method along withUrl.RouteUrl
to accomplish it.return Redirect(Url.RouteUrl(new { controller = "Thread", action = "ShowThreadLastPostPage", threadOid = threadId }) + "#" + postOid);
这篇关于ASP.Net MVC RedirectToAction锚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文