Return a JSON string explicitly from Asp.net WEBAPI?

前端 未结 6 1249
栀梦
栀梦 2020-11-27 03:30

In Some cases I have NewtonSoft JSON.NET and in my controller I just return the Jobject from my controller and all is good.

But I have a case where I get some raw JS

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 04:02

    sample example to return json data from web api GET method

    [HttpGet]
    public IActionResult Get()
    {
                return Content("{\"firstName\": \"John\",  \"lastName\": \"Doe\", \"lastUpdateTimeStamp\": \"2018-07-30T18:25:43.511Z\",  \"nextUpdateTimeStamp\": \"2018-08-30T18:25:43.511Z\");
    }
    

提交回复
热议问题