Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Can';t从JSON格式接收Asp.Net MVC5中的对象_Angularjs_Json_Asp.net Mvc - Fatal编程技术网

Angularjs Can';t从JSON格式接收Asp.Net MVC5中的对象

Angularjs Can';t从JSON格式接收Asp.Net MVC5中的对象,angularjs,json,asp.net-mvc,Angularjs,Json,Asp.net Mvc,有一个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

有一个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,但我没有得到一个block

型号:

   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':undefined}
更改为`headers:{'Content-Type':application/json}`将
标题:{'Content-Type':undefined}
更改为`headers:{'Content-Type':application/json}`