SPWeb.EnsureUser()注意AllowUnsafeUpdates=true

使用时一直报异常,后仔细看它的定义

SPWeb.EnsureUser
方法 (Microsoft.SharePoint)

Checks whether the specified login name belongs to a valid user of the Web
site, and if the login name does not already exist, adds it to the Web site.

它会对SPWeb进行更改操作,那么SPWeb.AllowUnsafeUpdates = true;就是免不了的了

原文地址:https://www.cnblogs.com/ruijian/p/2279063.html