I am getting an error
A Web exception occurred while attempting to issue the request. The remote server returned an error: (413) Request Entity Too Large.:
when trying to upload a file to a Sharepoint site from an ASP.Net Web Application. User adds selects a file via an ASP.Net File Upload control and the code below uploads it to Sharepoint. The file I am trying to upload is ~250k (i.e. not very large).
The code is as follows:
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.
}
}
I have the following set in the web.config
<httpRuntime maxRequestLength="1024000" />
It works fine if I use a text file that is a few k, so I think the basic idea is right (the SOAP message is formatted ok and the URL is correct). However I am told by the person running the SP site that it is configured to accept documents of up to 50MB in size.
Any ideas where I can start looking for problems?