I was working on a WCF web service that is hosted by SharePoint 2010 that provisions a users My Site and I kept getting this error message when trying to run the service:
Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.
In searching the issue, I found a workaround on the MSDN forums that works quite well: set the current HttpContext to null. When the current HttpContext is null, SharePoint does not know that the request was made during a GET request.
[csharp]// Save the current HttpContext to a variable to reuse later
var context = HttpContext.Current;
var serviceContext = SPServiceContext.Current;
var userProfileManager = new UserProfileManager(serviceContext);
var userProfile = userProfileManager.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);
if (userProfile != null)
{
if (userProfile.PersonalSite == null)
{
// Set the current HttpContext to null
HttpContext.Current = null;
userProfile.CreatePersonalSite();
}
}
// Reset the HttpContext
HttpContext.Current = context;[/csharp]
I found this extremely helpful and wanted to share.
SharePoint Online delivers
the powerful features of SharePoint without the
associated overhead of anaging he infrastructure on
your own. Flexible management options ensure that you still retain
the control
you need to meet the compliance requirements of your organization.
Sharepoint
developer
Sharepoint Site
Sharepoint Services
Sharepoint Designer
Sharepoint Consulting
Sharepoint Server