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