Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 Web Api最大参数长度_C# 4.0_Asp.net Mvc 5_Asp.net Web Api2 - Fatal编程技术网

C# 4.0 Web Api最大参数长度

C# 4.0 Web Api最大参数长度,c#-4.0,asp.net-mvc-5,asp.net-web-api2,C# 4.0,Asp.net Mvc 5,Asp.net Web Api2,我有一个非常简单的dto public class RisRequest { public string APIKey { get; set; } public string Message { get; set; } } 还有一个简单的web api [HttpPost] public HttpResponseMessage rad(RisRequest request) 99%的时间都是这样。但是当我点击一个消息长度超过正常值(>100000个字符,112kb)的

我有一个非常简单的dto

public class RisRequest
{
    public string APIKey { get; set; }
    public string Message { get; set; }
}
还有一个简单的web api

[HttpPost]
    public HttpResponseMessage rad(RisRequest request)
99%的时间都是这样。但是当我点击一个消息长度超过正常值(>100000个字符,112kb)的请求时,这个参数为null。注意APIKey仍然是好的,我的RISRESQUEST对象不是空的,但只有eMessage参数

我在谷歌上搜索了一下,尝试了很多选择

根据,我尝试设置httpconfig缓冲区

config.Formatters.FormUrlEncodedFormatter.ReadBufferSize = int.MaxValue/10;
我在中尝试了web.config选项



两个都不走运。所有其他的一些建议都是相同的变化。 你知道我哪里出错了吗

谢谢

根据

这是windows限制。在url中,参数是路径的一部分。windows限制路径段的长度

您应该在regedit中更改
urlsectionmaxlength

在以下注册表项中创建
DWORD

HKEY\U LOCAL\U MACHINE\System\CurrentControlSet\Services\HTTP\Parameters

urlsectionmaxcount

URL路径段的最大数目。如果为零,则计数以 ULONG的最大值

有效值范围0-16383

<system.webServer>
  <security>
   <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483648" />
   </requestFiltering>
  </security>
</system.webServer>
<system.web>
  <httpRuntime maxRequestLength="2097152" />
</system.web>