如何获得超过 Request.Form 的值
How can I get a value which I receive over Request.Form
所以在我的前端我传递了一个对象,它有一个 PersonId 和一个 FormData 对象。
const formData = new FormData();
for (let file of files){
formData.append(file.name, file,);
}
formData.append('currentId',this.UserId.toString());
const uploadReq = new HttpRequest('POST', 'https://localhost:5001/api/file',formData, {
reportProgress: true,
});
我在后端收到的 FormData 对象包含以下行:
var file = Request.Form.Files[0];
问题是如何获取 currentId 值?
我的一个方法是这样的:
var PersonId = Request.Form.Keys;
但这给了我这个回报,我不知道如何获得这个价值。
定义一个 StringValues 类型的变量:
StringValues id;
然后使用以下变量:
Request.Form.TryGetValue("currentId", out id);
所以在我的前端我传递了一个对象,它有一个 PersonId 和一个 FormData 对象。
const formData = new FormData();
for (let file of files){
formData.append(file.name, file,);
}
formData.append('currentId',this.UserId.toString());
const uploadReq = new HttpRequest('POST', 'https://localhost:5001/api/file',formData, {
reportProgress: true,
});
我在后端收到的 FormData 对象包含以下行:
var file = Request.Form.Files[0];
问题是如何获取 currentId 值?
我的一个方法是这样的:
var PersonId = Request.Form.Keys;
但这给了我这个回报,我不知道如何获得这个价值。
定义一个 StringValues 类型的变量:
StringValues id;
然后使用以下变量:
Request.Form.TryGetValue("currentId", out id);