I have this bit of code that triggers on click. When I set a breakpoint at SaveNewProduct
all the values are null. I tried to create a input object, I tried to add in each property manually, nothing worked. May I get any tips or suggestion.
var input = {
name: name,
type: type,
description: description,
category: category,
file: file.files[0],
acronym: acronym
};
$.ajax({
type: "POST",
url: '/Admin/SaveNewProduct',
processData: false,
data: {
name: name,
type: type,
description: description,
category: category,
file: file.files[0],
acronym: acronym,
input: input
},
success: function (response) {
alert("saved okay");
}
});
[HttpPost]
public async Task<ActionResult> SaveNewProduct(SaveNewProductInput input)
{
...
//breakpoint here, input values are all null
...
}
SaveNewProductInput.cs
public class SaveNewProductInput
{
public string Name { get; set; }
public string Acronym { get; set; }
public string Type { get; set; }
public string Category { get; set; }
public string Description { get; set; }
public HttpPostedFileBase File { get; set; }
}
I also tried remove processData, i Am presented with this error Uncaught TypeError: Illegal invocation