Reputation: 2286
I have a very simple dto
public class RisRequest
{
public string APIKey { get; set; }
public string Message { get; set; }
}
And a nice easy web api
[HttpPost]
public HttpResponseMessage rad(RisRequest request)
99% of the time this works. but when I hit a request where the Message is longer than the norm (>100,000 characters, and 112kb) then this parameter is null. note the APIKey is still good, my RisRequest object isn't null, but only th eMessage parameter.
I did some googling and tried a bunch of options
as per This link I tried setting the httpconfig buffer
config.Formatters.FormUrlEncodedFormatter.ReadBufferSize = int.MaxValue/10;
I tried the web.config options in this link
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
and
<system.web>
<httpRuntime maxRequestLength="2097152" />
</system.web>
and no luck with either. all other some suggest a variation of the same. Any ideas where I am going wrong?
Thank
Upvotes: 2
Views: 6460
Reputation: 1438
According to Max Parameter length in MVC
this is a windows restriction. in your url, the parameter is part of the path. windows restricts a path segments length.
you should change UrlSegmentMaxLength
in regedit.
create a DWORD
value in the following registery key
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters
UrlSegmentMaxCount
Maximum number of URL path segments. If zero, the count bounded by the maximum value of a ULONG.
Valid value range 0 - 16,383
Upvotes: 1