I have an ASP.NET MVC WebApplication where I am using the ASP.NET Web API framework.
Javascript code:
var data = new FormData();
data.append("filesToDelete", "Value");
$.ajax({
type: "POST",
url: "/api/FileAttachment/UploadFiles?clientContactId=" + clientContactId,
contentType: false,
processData: false,
data: data,
success: function (result) {
// Do something
},
error: function (xhr, status, p3, p4) {
// Do something
}
});
C# code (WebAPI):
public void UploadFiles(int clientContactId) {
if (!Request.Content.IsMimeMultipartContent()) {
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
var jsonContent = Request.Content.ReadAsStringAsync().Result;
}
How do I read jsonContent
based on a key value pair passed by the Javascript FormData?
I tried to do JsonConvert.DeserializeObject<?>
, but it requires a particular type to deserialize into.
I want to get the value of the key "filesToDelete"
passed from the Javascript FormData.
How can I get this value?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…