Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Getting number of comments from server object model using SocialCommentManager class
WhatsApp
Prasham Sabadra
Apr 11
2015
1.7
k
0
0
//using Microsoft.Office.Server.SocialData; - include this for SocialCommentManager
// Variable declaration
private
SocialCommentManager _commentManager =
null
;
private
Uri _currentUri =
null
;
_siteId = SPContext.Current.Site.ID;
_webId = SPContext.Current.Web.ID;
SPSecurity.RunWithElevatedPrivileges(
delegate
()
{
using
(SPSite site =
new
SPSite(_siteId))
{
using
(SPWeb web = site.OpenWeb(_webId))
{
_url = HttpContext.Current.Request.Url.ToString();
//Create Service Context
SPServiceContext _serviceContext =
SPServiceContext.GetContext(web.Site);
if
(!
string
.IsNullOrEmpty(_url))
{
_currentUri =
new
Uri(_url);
//Initialize SocialCommentManager
_commentManager =
new
SocialCommentManager(_serviceContext);
if
(_currentUri !=
null
)
{
_totalComments =
_commentManager.GetCount(_currentUri);
}
}
}
}
});
SocialCommentManager
Getting no of comments for current url
Up Next
Getting number of comments from server object model using SocialCommentManager class