【问题标题】:httpclient doesn't send correct number to webapihttpclient 没有向 webapi 发送正确的号码
【发布时间】:2021-05-11 21:05:22
【问题描述】:

我使用angular httpclient向asp.net core webapi发送数据,数据是personcontact,其中有contact_value、media、person_ID、person_contact_ID..这些数据。在 webapi 上,我可以正确接收字符串 data(contact_value, media..),但是,对于 int 数据,我收到了一些 0x0000ce6 或 0x000.. 一些数据(这不是我想要的..),你能告诉我吗如何在 webapi 中正确接收 person_ID 和 person_contact_ID .. 这些 int/number 数据?

tableelement.ts

confirmEditCreate_AddPerson(): boolean {
    //_personService: TestRDB2Service;
    if (this.id == -1)
      return this.source.confirmCreate(this);
    else
      
      try {
        this._http.put("https://localhost:5001/" + 'api/TestRDB2/AddUpdatePerson_Contact/', this.originalData).subscribe();      
      } catch (e) {
        return e
      }
    return true;
      //return this.source.confirmEdit(this);
  }

Testcontact.Controllers

        [HttpPut]
        [Route("AddUpdatePerson_Contact")]
        public int AddUpdatePerson_Contact([FromBody] personcontact personcontact)
        {
            return objtestRDB2.AddUpdatePerson_Contacts(personcontact);
        }

【问题讨论】:

    标签: angular httpclient asp.net-core-webapi


    【解决方案1】:

    并不是说它们是其他值。可能是您的 IDE,即我想您使用的 Visual Studio 将 int 值显示为 hexademical

    如果是这种情况,请检查 this answer 以了解如何更正显示的值

    【讨论】:

    • @Userstation 如果问题解决,请考虑接受答案
    【解决方案2】:

    您的代码似乎没有任何问题。您只需要通过右键单击禁用十六进制显示。

    【讨论】:

      猜你喜欢
      • 2014-11-23
      • 1970-01-01
      • 2020-12-01
      • 2016-05-18
      • 2015-01-04
      • 1970-01-01
      • 2018-07-20
      • 1970-01-01
      • 2014-04-07
      相关资源
      最近更新 更多