有一个JSON发送:
var formData = new FormData();
var test = {};
test.PosX1 = 0;
test.PosX2 = 10;
test.PosY1 = 10;
test.PosY2 = 1;
test.TemplateId = 0;
formData.append("block", test);
... +some file
var defer = $q.defer();
$http.post("/Templates/Create", formData,
{
withCredentials: true,
headers: { 'Content-Type': undefined },
//transformRequest: angular.identity
})
MVC控制器:
[HttpPost]
public JsonResult Create(string templateName, HttpPostedFileBase file, Models.ModelView.TemplateBlockView block)
{
我得到templateName,file,但我没有得到一个块。
型号:
public class TemplateBlockView
{
public int PosX1;
public int PosX2;
public int PosY1;
public int PosY2;
public int TemplateId;
}
以下是请求标题:
Provisional headers are shown
Accept:application/json, text/plain, */*
Content-Type:multipart/form-data; boundary=----
我尝试过不同的Content-Type,但没有结果。