在sharepoint开发中遇到的一些问题和解决方案
1.错误类型:
The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
解决方案:
Microsoft.SharePoint.Administration.SPWebApplication webApp = site.Site.WebApplication;
webApp.FormDigestSettings.Enabled = false;
SPFile spFile = site.Files.Add(fileUpload.FileName, contents);
spFile.Item.Update();
webApp.FormDigestSettings.Enabled = true;
web.AllowUnsafeUpdates = true;
site.AllowUnsafeUpdates = true;
2. 错误类型 :
在 sharepoint中报未知错误
解决方案:
在该站点下的配置文件里面修改以下节点
1.<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
改为:
<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
2.<customErrors mode="On " /> 改为:<customErrors mode="Off " />
3.<compilation batch="false" debug="false ">改为; <compilation batch="false" debug="true ">
修改后就会把错误源显示出来,总比报"未知错误"好吧!
3. 错误类型 :
Unable to serialize the session state. In 'StateServer' and 'SQL Server' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
解决 方案:
被使用的类必须标记为可序列化!
4.错误类型 :
如果配置好的sharepoint,也在同一个域,把用户加进了网站的成员组里面,但是该组里面的成员还是不能访问
解决方案:
请关闭防火墙。![如果报访问受限,则把成员加进网站的成员组里面]
4. 错误类型 :
Operation is not valid due to the current state of the object
解决方案:提升权限
SPSecurity.RunWithElevatedPrivilege
s(delegate() { SPSite site = new SPSite(http://oa:9000 );
SPWeb web = site.OpenWeb();
using (site)//...
});
或者:
private string GetPictureUrl(string loginName)
{
SPSite site = null;
SPWeb web = null;
using (site = new SPSite(mySiteUrl))
{
using (web = site.RootWeb)
{
web.AllowUnsafeUpdates = true;
ServerContext ctx = ServerContext.GetContext(site);
UserProfileManager profileMgr = new UserProfileManager(ctx);
if (HttpContext.Current != null)
{