0
试图从ASP.Net Web应用程序上传文件到SharePoint站点时,我得到一个错误上传文件到SharePoint返回413请求实体过大
A Web exception occurred while attempting to issue the request. The remote server returned an error: (413) Request Entity Too Large.:
。用户添加通过ASP.Net文件上传控件选择一个文件,下面的代码将其上传到Sharepoint。我想上传的文件是〜250k(即不是很大)。
的代码如下:
public string SharepointWebClientSOAPPost(Uri webService, string SOAPAction, string contentType, string postData, NetworkCredential networkCredential = null, string webProxy = "", NetworkCredential webserviceCredentials = null)
{
try
{
using (WebClient client = new WebClient())
{
if (string.IsNullOrEmpty(webProxy) && webserviceCredentials != null)
{
client.Proxy = new WebProxy(new Uri(webProxy));
client.Proxy.Credentials = webserviceCredentials;
}
if (networkCredential != null)
{
client.Credentials = networkCredential;
}
client.Headers.Add(HttpRequestHeader.ContentType, contentType);
client.Headers.Add("SOAPAction", SOAPAction);
// Apply ASCII Encoding to obtain the string as a byte array.
var byteArray = Encoding.ASCII.GetBytes(postData);
// Upload the input string using the HTTP 1.0 POST method.
var responseArray = client.UploadData(webService, "POST", byteArray);
// Decode and return the response.
var response = Encoding.ASCII.GetString(responseArray);
return response;
}
}
catch(Exception ex)
{
//etc.
}
}
我有以下在web.config设置
<httpRuntime maxRequestLength="1024000" />
,如果我用一个文本文件,是几k它工作正常,所以我认为基本思想是正确的(SOAP消息格式正确,URL正确)。但是,运行SP站点的人员告诉我,它配置为接受最大为50MB大小的文档。
任何想法,我可以开始寻找问题?
道歉在我的响应延迟 - 但这不工作(同错误)。该网站没有托管服务,因此我不认为这个错误是'接收',而是'发送' – glosrob 2014-10-10 11:47:14
请参阅[this](http://stackoverflow.com/questions/24009527/solved-wcf-远程服务器返回的错误413请求实体太大)和[this](http://stackoverflow.com/questions/884235/wcf-how-to-increase-message-size -quota)和[this](http://stackoverflow.com/questions/24930058/file-upload-the-remote-server-returned-an-error-413-request-entity-too-large) – Max 2014-10-10 13:30:32