C# 无法检索对WebApi的Post调用中冗长的base64(超过3 MB)字符串。我只是得到null而不是数据

C# 无法检索对WebApi的Post调用中冗长的base64(超过3 MB)字符串。我只是得到null而不是数据,c#,rest,asp.net-web-api,C#,Rest,Asp.net Web Api,我的请求如下所示: 用户代理:Fiddler 内容类型:application/json;字符集=utf-8 主机:localhost:12841 内容长度:4512954 在主体内部我有-->“Base64编码字符串” API控制器包含一个方法: [HttpPost] public bool SaveProductImage([FromBody]string image) { if(image!=null)

我的请求如下所示:

用户代理:Fiddler 内容类型:application/json;字符集=utf-8 主机:localhost:12841 内容长度:4512954

在主体内部我有-->“Base64编码字符串”

API控制器包含一个方法:

        [HttpPost]
        public bool SaveProductImage([FromBody]string image)
        {
            if(image!=null)
            var result =                         productImageRules.StoreSingleImageOnDisk(image.ToString());            
            return result;
        }

请确保允许应用程序在web.config中接收大型帖子

这里有一个10mb的例子

对于ASP.NET


对于IIS


这是我的解决方案。 在web.config中(在服务器中)

----------
----------
----------
----------

好看

请提供更多详细信息非常简单…我想使用webapi在磁盘上保存图像。所以我想做的是,我通过fiddler/postman将base64encoded(通过将图像转换为base64string)字符串发送到webapi,但是如果字符串的大小超过3Mbs,webapi将为空,对于小数据,它可以正常工作。我一直在努力摆脱这个问题,但没有运气,我找不到任何职位,可以给我这个问题的答案我也有这个问题。我已经应用了您的解决方案,但完整图像仍无法作为base64上传。只是图像的一部分。当im使用共享web场托管服务时,托管服务是否会覆盖此设置?是的,很可能,请先在本地尝试测试。
----------
<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
     <standardEndpoints>           
    <webHttpEndpoint>
 <standardEndpoint name="" helpEnabled="true"automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json" crossDomainScriptAccessEnabled="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" /> 
    </webHttpEndpoint>
  </standardEndpoints>
</system.serviceModel>

----------
<system.web.extensions> 
   <scripting> 
      <webServices> 
        <jsonSerialization maxJsonLength="2147483647"/> 
      </webServices> 
   </scripting> 
</system.web.extensions> 
 <system.web>
    <httpRuntime targetFramework="4.5" maxRequestLength="2097151"     useFullyQualifiedRedirectUrl="true"     executionTimeout="14400"  />
----------
<system.webServer>
    <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="2147483647" />
    </requestFiltering>
  </security>
----------