C# 将文件上载到Sharepoint返回413请求实体太大

C# 将文件上载到Sharepoint返回413请求实体太大,c#,wcf,sharepoint,post,webclient,C#,Wcf,Sharepoint,Post,Webclient,我犯了一个错误 尝试发出请求时发生Web异常。远程服务器返回错误:(413)请求实体太大: 尝试从ASP.Net Web应用程序将文件上载到Sharepoint网站时。用户添加通过ASP.Net文件上载控件选择文件,下面的代码将其上载到Sharepoint。我试图上传的文件约为250k(即不是很大) 代码如下: public string SharepointWebClientSOAPPost(Uri webService, string SOAPAction, string contentTy

我犯了一个错误

尝试发出请求时发生Web异常。远程服务器返回错误:(413)请求实体太大:

尝试从ASP.Net Web应用程序将文件上载到Sharepoint网站时。用户添加通过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消息的格式是ok的,URL是正确的)。但是,运行SP站点的人员告诉我,它已配置为接受大小高达50MB的文档


有什么想法可以让我开始查找问题吗?

您的代码使用WCF上传文件,而不是ASP.NET。为此,您必须配置web.configmaxReceivedMessageSize,如下所示:

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding maxReceivedMessageSize="10485760">

      </binding>
    </basicHttpBinding>
  </bindings>  
</system.serviceModel>

对于我的回复延迟表示歉意-但这不起作用(相同的错误)。该网站没有托管该服务,因此我认为错误不在于“接收”,而在于“发送”,请参见和