C# SharePoint Office 365应用程序,增加文件上载大小

C# SharePoint Office 365应用程序,增加文件上载大小,c#,sharepoint,sharepoint-apps,C#,Sharepoint,Sharepoint Apps,我正在visual studio中开发SharePoint Office 365应用程序。我使用了FileUpload控件,通过使用CSOM将文件上载到SharePoint文档库 我正面临一个新的问题。SharePoint Office 365应用程序不允许在我的自定义页面中上载大于3 MP的文件,并显示以下错误消息 Maximum request length exceeded. Description: An unhandled exception occurred during the e

我正在visual studio中开发SharePoint Office 365应用程序。我使用了FileUpload控件,通过使用CSOM将文件上载到SharePoint文档库

我正面临一个新的问题。SharePoint Office 365应用程序不允许在我的自定义页面中上载大于3 MP的文件,并显示以下错误消息

Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length exceeded.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): Maximum request length exceeded.]
   System.Web.HttpRequest.GetEntireRawContent() +9726860
   System.Web.HttpRequest.GetMultipartContent() +63
   System.Web.HttpRequest.FillInFormCollection() +165
   System.Web.HttpRequest.EnsureForm() +75
   System.Web.HttpRequest.get_Form() +12
   System.Web.HttpRequest.get_HasForm() +9728411
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +95
   System.Web.UI.Page.DeterminePostBackMode() +69
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +130
请帮助我,如何在SharePoint应用程序中增加文件上载的最大大小

提前谢谢

 using (ClientContext context = TokenHelper.GetClientContextWithAccessToken(Request.QueryString["SPHostUrl"].ToString(), accessToken))
                {
                    //Get Web and List object
                    Web web = context.Site.OpenWeb("test");
                    List list = web.Lists.GetByTitle("Documents");
                    //Open file
                    System.IO.FileStream stream = System.IO.File.OpenRead(txtFilePath.Text);
                    //Create new file creation info object        
                    FileCreationInformation fileCreation = new FileCreationInformation();
                    fileCreation.ContentStream = stream;
                    fileCreation.Overwrite = true;
                    fileCreation.Url = "test";
                    //Add File to documents library
                    File uploadedFile = list.RootFolder.Files.Add(fileCreation);
                    list.Update();
                    web.Update();
                    context.ExecuteQuery();
                }

尝试使用此解决方案上载文件。

以下示例演示如何使用将文件上载到O365:

用法

当上传大小超过3MB的文件时,它对我有效

如何更新文件属性

//Update Title property for File object
var uploadedFile = ctx.Web.GetFileByServerRelativeUrl(fileRelativeUrl);
uploadedFile.ListItemAllFields["Title"] = "New Title";
uploadedFile.ListItemAllFields.Update();
ctx.ExecuteQuery();

这与我的代码类似。实际上,当我单击“上载”按钮时,编译器不会首先转到此代码并显示消息。您能帮助我,我们如何更改应用程序的web.config文件中的上载文件大小限制。请尝试在web.config中使用:in System.web节这在SharePoint Apps web.config中是不允许的。当我们将其添加到web.config时,它会显示以下错误。HTTP错误500.19-内部服务器错误无法访问请求的页面,因为该页面的相关配置数据无效。感谢您的回复。我想在这里补充一点。我们是否可以在保存文件时添加一些属性,如(名称、标题或某些字段)。
//Upload file into Assets library
UploadFile(ctx, "/Assets", @"C:\VideoArchive\VideoSample.mp4");
//Update Title property for File object
var uploadedFile = ctx.Web.GetFileByServerRelativeUrl(fileRelativeUrl);
uploadedFile.ListItemAllFields["Title"] = "New Title";
uploadedFile.ListItemAllFields.Update();
ctx.ExecuteQuery();