У меня есть скрытая веб-часть, которая читает значение строки запроса "optout = Yes".Это optout = Да, тогда мне нужно обновить свойство профиля.Если вы видите в моем коде.Ошибка " userprof.Commit () " и выдается ". Обновления в настоящее время запрещены для запросов GET. Чтобы разрешить обновления для GET, установите свойство" AllowUnsafeUpdates "в SPWeb ",Любое решение для этого?
private void OptOutMemberInvitation()
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
//update the invitee's Profile property
UpdateInviteeOptOutProfile(InviteeConstitID);
});
}
private void UpdateInviteeOptOutProfile(string inviteeSiteColUrl)
{
ServerContext sc = ServerContext.Current;
UserProfileManager upm = new UserProfileManager(sc);
//Get the user profile
Microsoft.Office.Server.UserProfiles.UserProfile userprof = upm.GetUserProfile(MemberConstitID);
SPWeb web = userprof.PersonalSite.RootWeb;
//make sure we can update our list
web.AllowUnsafeUpdates = true;
web.Update();
//Update the OptOut Property on the user's profile.
userprof["OptOut"].Value = "Yes";
userprof.Commit(); //Fails here
//update the list item to persist it to list
web.AllowUnsafeUpdates = false;
//siteCol.Close();
//siteCol.Dispose();
}