The first two days when doing SharePoint list scoring development encountered a small problem:
The Socialratingmanager class in the SharePoint server-side object model can be used for scoring-related operations, but creating instances of this class requires HttpContext objects, and itemupdated Event cannot get to HttpContext because user access is now over
The HttpContext.Current is a available within the constructor of your event receiver when handling synchronous events L Ike Itemadding, ItemUpdating.
What should we do at this time? Many people have suggested solutions:
- Try using the ItemUpdating event to pass the HttpContext.Current to the field in the construction method, and then use it in the event response method.
- Still using itemupdated Event to construct HttpContext, the following two links are constructed using the same method in SharePoint 2010 and 2013, respectively HttpContext
http://www.sharepointpals.com/post/Programmatically-Manage-List-Items-Rating-with-Social-Rating-Manager-in-SharePoint-2013
https://pholpar.wordpress.com/2011/02/16/how-we-can-set-rating-in-the-name-of-other-users-from-code/
3. Fully mimic the first link practice, develop a custom WCF deployment method in SharePoint that is related to a SharePoint application, call it, complete the scoring in custom WCF
I tried it. The first method is feasible,
Step one, set the Ed event as the synchronization event
Step two, get HttpContext in the ING method, save it with a static variable.
So we can get HttpContext.
If Bo friends think of a better way, send to encourage
SharePoint Event Receiver Ed Method gets HttpContext