Return “raw” json in ASP.NET Core 2.0 Web Api

后端 未结 2 698
臣服心动
臣服心动 2020-11-29 08:11

The standard way AFAIK to return data in ASP.NET Core Web Api is by using IActionResult and providing e.g. an OkObject result. This works fine with

2条回答
  •  Happy的楠姐
    2020-11-29 08:36

    In your action, replace Ok() with the Content() method, which lets you set the content (raw content), content type, and status code of your response: https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.contentresult?view=aspnetcore-2.0

提交回复
热议问题