0

SPWeb の名前変更を試みると、次の SPException が表示されます。

Exception SPException - The security validation for this page is invalid.  Click Back in your Web browser, refresh the page, and try your operation again. - Failed to create workgroup registration entry

ここで何が問題になるのか、何か考えはありますか? 関連するコードは次のとおりです。

SPSecurity.RunWithElevatedPrivileges(() =>
         {
             using (SPWeb thisWeb = site.OpenWeb(webUrl))
             {  
                 thisWeb.Title = newName;
                 thisWeb.Update();
             }
          });
4

1 に答える 1

2

1) SPWeb.AllowUnsafeUpdates = true を設定します
2) ValidateFormDigest を使用して FormDigest を検証する必要がある場合があります

SPSecurity.RunWithElevatedPrivileges(() =>
{
    using (SPWeb thisWeb = site.OpenWeb(webUrl))
    {  
        try
        {
            thisWeb.AllowUnsafeUpdates = true;

            if (!thisWeb.ValidateFormDigest())
                throw new InvalidOperationException("Form Digest not valid");

            thisWeb.Title = newName;
            thisWeb.Update();
        }
        finally
        {
            if(thisWeb != null)
                thisWeb.AllowUnsafeUpdates = false;
        }
    }
});
于 2009-11-04T23:00:26.177 に答える