I want to process a file coming from a post request.
The file looks like this:
first line: text1
second line: empty line
third line: text2
an example:
”
asdasdasd1
asdasdasd2
“
so far i processed the file like this:
byte[] data = Request.BinaryRead(Request.TotalBytes);
String processedfile = Encoding.UTF8.GetString(data);
But this was i lose the page breaks and the whole string becomes 1 line instead of 3.
How can i process the resquest where at the end i can keep the page breaks?
Thanks in advance!
Sincerely,
Zoli
Since you’re not using an HTML upload control on the page (which would preserve the entire file without issue) – my guess is that the significant whitespace in your ‘file’, isn’t percent-encoded (or URL encoded: http://en.wikipedia.org/wiki/Percent-encoding) and so is getting dropped.
Your client needs to URL encode the file contents otherwise stuff like spaces, tabs, etc will most likely be lost.