簡體   English   中英

.Net Core Web api return just based props

[英].Net Core Web api return just based props

public ActionResult LoginGet([FromBody]PostHelperEntity<Sw_User_LoginDto> helperEntity)
{
   var result = _service.GetSingle(x => x.UserName == helperEntity.Entity.UserName  && x.Password == helperEntity.Entity.Password);
   return Ok(result);
}

我的actionresult是這樣的,它在result中正確返回了數據。 但是當我使用 return Ok(result) 時。 它返回基於道具。

這是結果;


{
    "data": {
        "id": 1,
        "createDateTime": null,
        "updateDateTime": null
    },
    "listData": null,
    "success": true,
    "message": null
}

結果變量有姓名列。

如果我使用

 return Ok(JsonConvert.SerializeObject(result));

數據在 postman 中正確返回。

結果變量

在此處輸入圖像描述

郵遞員結果

在此處輸入圖像描述

我為基礎結構解決了它,

添加這個nuget;

Microsoft.AspNetCore.Mvc.NewtonsoftJson

然后將這些代碼添加到您的 program.cs 或 startup.cs

builder.Services.AddControllers().AddNewtonsoftJson();

現在我得到了所有道具。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM