简体   繁体   English

如何在asp.net mvc 4剃须刀链接中使用DISQUS计数链接?

[英]How can I use the DISQUS count link in my asp.net mvc 4 razor link?

I have a razor link that looks like this: 我有一个看起来像这样的剃须刀链接:

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

In the Disqus install info it says: 在Disqus安装信息中,它说:

Place the following code before your site's closing tag: 将以下代码放在您网站的结束标记之前:

<javascript>

I have done that. 我已经做到了。

Then it says step 2: 然后说步骤2:

Append #disqus_thread to the href attribute in your links. #disqus_thread附加到链接中的href属性。 This will tell Disqus which links to look up and return the comment count. 这将告诉Disqus查找哪些链接并返回评论数。

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

Question

How can I add #disqus_thread when i'm using a htmlhelper extension? 使用#disqus_thread扩展程序时如何添加#disqus_thread

What I've tried 我尝试过的

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

but that generates: 但这会产生:

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

您需要这样的转义字符:

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

这是我发现的最好方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM