I am running an Angular JS application on top of a C#/.NET legacy framework.
I need to upload & save a file along with some POST data variables, and therefore using the FormData
api.
let formData = new FormData();
formData.append('co-lo-import', file);
formData.append('data', someString);
Then I make an xhr request like so:
$http.post("//some/dot-net/endpoint/Default.aspx",
formData,
{ headers: { "Content-Type" : "multipart/form-data" }
});
On the .NET side, I'm trying to grab these values from the Request
variable.
string someString = Request.Form['data'];
HttpFileCollection uploadedFiles = null;
if(Request.Files != null){
uploadedFiles = Request.Files;
}
But these values are always empty. There is never anything in Request.Form
I tried Request.Form.Get("data")
which comes up empty also.
I am seeing the file and data in the request payload:
How can I grab this data on the back-end using .NET?