Hi all,
I've recently migrated a web app from a Windows Azure App Service to a Linux one.
I'm now running into a problem that I had not anticipated.
Since I'm new to running on Linux I thought I'd ask here.
So basically the web app allows users to upload a text file and the web app then sends the text to a web service running on Windows for further processing.
Here's the gist of it:
string content = await IFormFile.ReadAsStringAsync();
string json = JsonConvert.SerializeObject(new { content, something, somethingElse });
var httpcontent = new StringContent(json, Encoding.UTF8, MediaTypeNames.Application.Json);
using HttpResponseMessage response = await client.PostAsync("MyEndpoint", httpcontent).ConfigureAwait(false);
var lines = content.Split(Environment.NewLine);
I'd expected Split(Environment.NewLine) would return hundreds of lines, but I'm getting only one when I call the endpoint from the Linux web app.
My guess is that Linux sends the new lines as \n while Windows uses \r\n.
I'd had hoped the JSON would serialize to \n and then the service on Windows would deserialize it as \r\n.
I've probably used plenty services running on Linux and I've never had to worry about my new lines.
I don't want to know what my service runs on and adjust my new lines accordingly.
What am I doing wrong?
The web app uses .NET8 and the web service uses .NET6. Both are running in Azure Web Apps.
What I have tried:
Plenty of logging to find the problem.
I know of workarounds, like splitting in the Linux app and then sending the lines to Windows, or splitting on \n instead of Environment.NewLine.
Did some googling, but couldn't find an actual answer to my problem.