InvalidDataException: Line length limit 100 exceeded
See original GitHub issueWhen uploading data files with RestSharp to a .Net Core 2.1 REST interface, I get this error on some files:
System.IO.InvalidDataException: Line length limit 100 exceeded.
at Microsoft.AspNetCore.WebUtilities.BufferedReadStream.ReadLineAsync(Int32 lengthLimit, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
at Microsoft.AspNetCore.WebUtilities.MultipartReader.ReadNextSectionAsync(CancellationToken cancellationToken)
When I do the same operation with Insomnia, I do not get any error, only with RestSharp.
I have read here https://stackoverflow.com/questions/44642701/microsoft-aspnetcore-webutilities-line-length-limit-100-exceeded that there is a problem with the line ending formats, but this is the only article about it.
The controller signature is very simple:
[HttpPost, DisableRequestSizeLimit]
public async Task<IActionResult> AddPictureAsync(
IFormFile Picture,
IFormFile Thumbnail,
string Title)
{
and the code to send is:
var Request = new RestRequest("picture", Method.POST) { AlwaysMultipartFormData = true };
Request.AddHeader("SessionId", SessionId);
Request.AddFile("Picture", PhotoData.ToArray(), Photo.PhotoUrl);
Request.AddFile("Thumbnail", ThumbnailData, Photo.PhotoUrl.Replace(".jpg", "-t.jpg"));
Request.AddParameter("Title", Photo.Title ?? string.Empty, ParameterType.GetOrPost);
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Microsoft.AspNetCore.WebUtilities Line length limit 100 ...
I've look at Microsoft.AspNetCore.WebUtilities and found where the error is coming from but not sure how to avoid 100 character limit. I have ......
Read more >Line length limit 100 exceeded on multipart form request
After debugging the bytes of the incoming request Body, it only has new line characters and no carriage returns which BufferedReadStream ...
Read more >FormOptions.MultipartBodyLengthLimit Property
Forms sections that exceed this limit will throw an InvalidDataException when parsed. Defaults to 134,217,728 bytes, which is approximately 128MB.
Read more >Line length limit 100 exceeded on multipart form request
When making the following request on my mac: - curl -X POST \ http://localhost:8080/upload \ -H 'Content-Type: multipart/form-data; ...
Read more >How do I can fix this: multipart body length limit 16384
i.e. you want to get picture, so the web api read files from server, and return base64 string. and client (xamarin) decode from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there an ETA for this? right now I’ve to move code away from RestSharp in order to have the calls succeed.
I’d like to point you gents to https://tools.ietf.org/html/rfc2616. The sequence of characters separating header and body has to be CRLFCRLF, so \r\n\r\n, regardless of what system you’re sending from or to. Anything else and every standardconforming webserver (nginx, haproxy, apache among others) will fail to understand the request properly.