我在我正在建立的博客上使用Facebook评论插件.它有一些FBXML标记,由页面上引用的facebook javascript解释.
这一切都很好,但我必须将当前的,完全限定的URL传递给插件.
<div style="width: 900px; margin: auto;">
<div id="fb-root"></div>
<fb:comments href="URL HERE" num_posts="10" width="900"></fb:comments>
</div>
Run Code Online (Sandbox Code Playgroud)
获取当前页面的URL的最佳方法是什么?请求URL.
这是我的解决方案的最终代码:
<fb:comments href="@Request.Url.AbsoluteUri" num_posts="15" width="900"></fb:comments>
Run Code Online (Sandbox Code Playgroud) 我需要RoutData通过ASP.NET MVC应用程序中的给定URL字符串来获取.
我找到了HttpContextBase基于URL字符串模拟的RouteTable.Routes.GetRouteData()方法,然后将其传递给Route Parsing(Uri to Route)线程中的方法.
如何使用URL字符串模拟HttpContextBase检索?RouteDataRouteTable.Routes.GetRouteData()
或者是否有另一种RouteData通过URL 检索的方法?