문제

현재 사용자가 현재 사이트를 따르는 것을 확인 해야하는 내 aspx.cs 파일에 메서드가 있습니다. ULS를 확인하면이 기능을받습니다 :

prosword.followitem : 예외 : Microsoft.SharePoint.SpException : 이 페이지의 보안 유효성 검사가 유효하지 않습니다. 다시 클릭하십시오 웹 브라우저, 페이지를 새로 고침하고 작업을 다시 시도하십시오. ---> System.Runtime.InteropServices.comException : 보안 유효성 검사 이 페이지의 경우 유효하지 않습니다. 웹 브라우저에서 다시 클릭하십시오. 새로 고침 페이지를 사용하고 작업을 시도하십시오 adain.0x8102006d

URL http://removedlink/ 를 따르지 못했습니다.

microsoft.office.server.social.spsocialfollowingmanager.follow : Microsoft.Office.Server.UserProfiles.FollowedContentException : InternalError : 항목을 따르지 못했습니다 x at. Microsoft.Office.Server.UserProfiles.FollowedContent.FollowItem (이전에 항목, 부울 IsInternal)

내 코드는 다음과 같습니다.

 protected void ToggleUserFollowSite(object sender, EventArgs e)
        {

                var spWeb = SPContext.Current.Web;
                var currentsite = SPContext.Current.Site;
                var currentUser = spWeb.CurrentUser.LoginName;
                SPSecurity.RunWithElevatedPrivileges(delegate
                    {
                        using (var site = new SPSite(spWeb.Site.ID))
                        {
                            using (var web = site.OpenWeb(spWeb.ID))
                            {


                                SPServiceContext context = SPServiceContext.GetContext(currentsite);                                                                      
                                var profile = new UserProfileManager(context);                                    
                                var user = profile.GetUserProfile(currentUser);                                   
                                var followingManager = new SPSocialFollowingManager(user, context);                                    
                                var actorInfo = new SPSocialActorInfo();
                                actorInfo.ActorType = SPSocialActorType.Site;
                                actorInfo.ContentUri = new Uri(web.Url);
                                followingManager.Follow(actorInfo);

                            }
                        }
                    });
            }
.

디버깅 할 때이 값은 .follow () 메서드에서 얻는 예외입니다.

{ "내부 오류가 발생했기 때문에 작업이 실패했습니다. 내부 이름 유형 : Microsoft.Office.Server.UserProfiles.FollowedContentException. 내부 오류 코드 : 11. "}

도움의 도움이 를 이해합니다

도움이 되었습니까?

해결책

첫째, RunWitheLevatedPrivileges 위임 내에서 새로 생성 된 Spsite 및 SPWeb 인스턴스 만 사용해야합니다.코드에서 다음 행을 변경하십시오

SPServiceContext context = SPServiceContext.GetContext(currentsite);

이 하나씩 :

SPServiceContext context = SPServiceContext.GetContext(site);
.

다른 문제는 페이지에서 보안 유효성 검사이며 validateFormDigest 메소드는 코드가 쓰기 작업을 수행하기 때문에 표고를 수행하기 전에 validateFormDigest 메소드입니다.spsecurity.runwitheLevatedPrivileges 앞에 다음 행을 추가하십시오.

SPUtility.ValidateFormDigest();
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top