I have the following code which posts file to ASP.net page:
using (var Client = new WebClient())
Client.UploadFile("http://localhost:1625/Upload.aspx", @"TestFile.csv");
On the server page I read the contents of the request:
var Contents = new byte[Request.InputStream.Length];
Request.InputStream.Read(Contents, 0, (int)Request.InputStream.Length);
This is what I get in the contents:
-----------------------8cf2bdc76fe2b40
Content-Disposition: form-data; name="file"; filename="TestFile.csv"
Content-Type: application/octet-stream
1;Test 1
2;Test 2
3;Test 3
4;Test 4
5;Test 5
-----------------------8cf2bdc76fe2b40--
Actual file contents are just 1;Test 1 ... 5;Test 5.
My question is how to get only file contents and not the whole request with headers?
Try this, get the posted file first: