我有一个将 .pdf 保存到 SharePoint 文档库的 Windows 应用程序。除了这个文件外,它工作正常。每当我对这个 10.1MB 的文件使用 SaveBinaryDirect 时,都会出现以下异常:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.File.SaveBinary(ClientContext context, String serverRelativeUrl, Stream stream, String etag, Boolean overwriteIfExists, SaveBinaryCheckMode checkMode)
at Microsoft.SharePoint.Client.File.SaveBinaryDirect(ClientContext context, String serverRelativeUrl, Stream stream, Boolean overwriteIfExists)
at BKWatch.BKWatchViewModel.UploadDocument(String siteURL, String documentListName, String documentListURL, String documentName, Byte[] documentStream, Int64 AccountId, String DebtorName, Nullable`1 Pages, String Title)
我已经尝试过以下方法:
clientContext.PendingRequest.RequestExecutor.WebRequest.KeepAlive = false;
System.Net.ServicePointManager.MaxServicePointIdleTime = 600000;
clientContext.RequestTimeout = 600000;
在 SharePoint 中增加最大大小 - 已经达到 50 MB 在 IIS web.config 中增加最大大小 - 已经达到 2GB
谢谢。