2013-05-14 32 views
1

我有一個剃鬚刀鏈接,看起來像這樣:如何在我的asp.net mvc 4 razor鏈接中使用DISQUS count鏈接?

@Html.ActionLink("Comment", "Comment", new { id = item.NewsId }) 

在Disqus安裝信息,它說:

將您的網站的關閉標籤之前,下面的代碼:

<javascript> 

我已經做到了。

於是說第2步:

追加#disqus_thread在你的鏈接href屬性。這將告訴Disqus哪些鏈接查找並返回評論數量。

例如:<a href="http://foo.com/bar.html#disqus_thread">Link</a>

問題

如何添加#disqus_thread當我使用的HtmlHelper擴展?

我已經試過

@Html.ActionLink("Comment", "Comment", new { id = item.NewsId + "#disqus_thread" }) 

但產生:

<a href="/Home/Comment/4656%23disqus_thread">Comment</a> 
+0

你想幫忙什麼? – SLaks

+0

我更新了問題 – Obsivus

回答

0

你需要轉義字符是這樣的:

@Html.ActionLink("Comment", "Comment", new { id = item.NewsId + "**&#35;**disqus_thread" }) 
0

這是我找到的最好辦法要做到這一點:

@Html.Raw(HttpUtility.UrlDecode(Html.ActionLink(item.Title, "ViewPost", "Posts", new { id = item.Id, slug = item.URL + "#disqus_thread" }, null).ToString()))