C# 将json从angular发送到c时,值为0或null#

C# 将json从angular发送到c时,值为0或null#,c#,json,api,angular,post,C#,Json,Api,Angular,Post,我的Angular&C项目有问题。我是个乞丐,我有这个问题。当我将json从angular发送到C#(POST)时,虽然json有值,但C#没有得到任何东西(int的值为0,string的值为null)。我不知道我做错了什么。Json具有以下结构: [{"delegacion":11,"municipio":1,"ejercicio":2017,"ninterno":-1,"tipo":"T"}] 我的代码 棱角的 preparaTarea(){ this.data.push({'de

我的Angular&C项目有问题。我是个乞丐,我有这个问题。当我将json从angular发送到C#(POST)时,虽然json有值,但C#没有得到任何东西(int的值为0,string的值为null)。我不知道我做错了什么。Json具有以下结构:

[{"delegacion":11,"municipio":1,"ejercicio":2017,"ninterno":-1,"tipo":"T"}]
我的代码

棱角的

preparaTarea(){    
this.data.push({'delegacion':this.delegacion,
                    'municipio':this.municipio,
                    'ejercicio':this.ejercicio,
                    'ninterno':this.ninterno,
                    'tipo':this.tipo_producto});

     this._DelegationService.sendPtipo(this.data)
        .subscribe(res=>{
                this.data = res;
              },             
              (err) =>console.log(err));  


    }

sendPtipo(data){
        let headers = new Headers({ 'Content-Type': 'application/json' });
        let options = new RequestOptions({ headers: headers });
        let urlPtipo ='http://localhost:50790/ApiProductoTipo/CalculaPTRecinto';

        let body = JSON.stringify(data);
        console.log(body);

    return this._http.post(urlPtipo , body , options)
                   .map(data => {alert('ok');})
                   .catch(this.handleError);
    }

    private handleError(error: Response) {
        console.error(error);
        return Observable.throw(error.json().error || 'Server error');
    }}
c#


调试时,delegacion、市政等的值为0,tipo为null。有什么想法吗?非常感谢

我终于解决了这个问题

  preparaTarea() {
     //Changing array by this
    let datos = { "delegacion":this.delegacion,
                  "municipio":this.municipio,
                  "ejercicio":this.ejercicio,
                  "ninterno":this.ninterno,
                  "tipo":this.tipo_producto
                  };  

    this._CalculoPTService.sendPtipo(datos)
      .subscribe(res => {
        datos = res;
      },
      (err) => console.log(err));
  }

通过关注属性的顺序,尝试发布硬代码数据,并检查您是否不应该发布数组。如果您使用Postman或fiddler先检查rest端点,然后在成功检查该端点后,继续使用硬代码对象,然后在代码中进行检查,则会更好
  preparaTarea() {
     //Changing array by this
    let datos = { "delegacion":this.delegacion,
                  "municipio":this.municipio,
                  "ejercicio":this.ejercicio,
                  "ninterno":this.ninterno,
                  "tipo":this.tipo_producto
                  };  

    this._CalculoPTService.sendPtipo(datos)
      .subscribe(res => {
        datos = res;
      },
      (err) => console.log(err));
  }