类似facebook的按钮iframe,在asp.net razor模板中打印动态url
我在umbraco cms中有一个asp.net网站,在那里我可以使用razor模板创建一些宏。 我想在页面中集成一个类似facebook的按钮, 只有当我将intire iframe粘贴到razor宏中并将该宏合并到我的母版页上时,这才有效 但是,如果我想包括一些参数, 我从代码片段中取出iframe URL,将另一个参数粘贴到该URL中 它停止工作了 但是,渲染后,两个iframe url完全相同 有人知道我如何确保Facebook iframe参数中包含正确的站点url可以更改吗?(取决于我在umbraco cms中绑定的主机名) 以下是我的razor代码,它不起作用:类似facebook的按钮iframe,在asp.net razor模板中打印动态url,asp.net,razor,umbraco,facebook-like,Asp.net,Razor,Umbraco,Facebook Like,我在umbraco cms中有一个asp.net网站,在那里我可以使用razor模板创建一些宏。 我想在页面中集成一个类似facebook的按钮, 只有当我将intire iframe粘贴到razor宏中并将该宏合并到我的母版页上时,这才有效 但是,如果我想包括一些参数, 我从代码片段中取出iframe URL,将另一个参数粘贴到该URL中 它停止工作了 但是,渲染后,两个iframe url完全相同 有人知道我如何确保Facebook iframe参数中包含正确的站点url可以更改吗?(取决于
@{
var currentLangPath = "www.newurl.com";
var iframeSource = "http://www.facebook.com/plugins/like.php?app_id=207125959336150&href=" + currentLangPath + "&send=false&layout=button_count&width=110&show_faces=false&action=like&colorscheme=dark&font=arial&height=21";
}
<a href="#visitFanpage"><img src="/images/facebook_logo.jpg" alt="Solex Facebook" /></a>
<p>Become part of the community, and feel free to share your experience.</p>
<div class="social">
<iframe src="@iframeSource" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:25px;" allowTransparency="true"></iframe>
</div>
@{
var currentLangPath=“www.newurl.com”;
变量iframeSource=”http://www.facebook.com/plugins/like.php?app_id=207125959336150&href=“+currentLangPath+”&;send=false&;layout=button\u count&;width=110&;show\u faces=false&;action=like&;colorscheme=dark&;font=arial&;height=21”;
}
成为社区的一部分,自由分享你的经验
以下是Razor文件的内容:
<a href="#visitFanpage"><img src="/images/facebook_logo.jpg" alt="Solex Facebook" /></a>
<p>Become part of the community, and feel free to share your experience.</p>
<div class="social">
<iframe src="http://www.facebook.com/plugins/like.php?app_id=207125959336150&href=www.newurl.com&send=false&layout=button_count&width=110&show_faces=false&action=like&colorscheme=dark&font=arial&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:25px;" allowTransparency="true"></iframe>
</div>
成为社区的一部分,自由分享你的经验
请注意,这两个Razor文件的输出完全相同,因此我发现动态URL文件不起作用非常奇怪。输出实际上并不相同,iframeSource变量经过HTML编码,因此“&;”变成:
&;amp代码>
你可以做两件事:
删除iframeSource中每个“&”之后的“amp;”
使用@Html.Raw(iframeSource)代替@iframeSource
该死的,应该查看实际的源代码,而不是从firebug获取呈现的url,firebug已经解码了实体,所以url看起来是相同的。谢谢你的提示,我马上去试试