SharePoint Event Receiver Ed Method gets HttpContext

Source: Internet
Author: User
Tags httpcontext

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:

    1. 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.
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.