I have a asp.net website in the umbraco cms, there I can use razor templating to create some macros. I want to integrate a facebook like button in the page, this works ONLY when I paste the intire iframe in a razor macro and incorporate the macro on my masterpage.
Though, if I want to include some parameters, and I take the iframe URL out of the code snippet to paste another parameter inside that url it stops working.
However, after rendering both the iframe url is 100% identical.
Anyone got an idea on how I can make sure that the correct site url is in that Facebook iframe parameter can be changed? (depending on the hostname I bind in the umbraco cms)
Here is my razor code that does not work:
@{
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>
Here is the content of a Razor file that does work:
<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>
Note that both these Razor files have EXACTLY the same output, so I find it very weird that the dynamic URL one does not work.
The output isn't actually the same, the iframeSource variable gets HTML encoded and therefore an "&" turns into:
&amp;
You could do two things:
- Remove "amp;" after each "&" in the iframeSource
- Instead of @iframeSource, use @Html.Raw(iframeSource)
精彩评论