【发布时间】:2018-01-13 04:02:33
【问题描述】:
我需要使用的供应商 API 发送一个 POST 请求,内容类型为:text/plain 和正文中的 JSON。
如何在 .net core 1.0 web api 中解析它?
我确定我需要做类似于this(下面的代码)答案的事情,但我不知道如何在 web api 中。
public class RawContentTypeMapper : WebContentTypeMapper
{
public override WebContentFormat GetMessageFormatForContentType(string contentType)
{
switch (contentType.ToLowerInvariant())
{
case "text/plain":
case "application/json":
return WebContentFormat.Json;
case "application/xml":
return WebContentFormat.Xml;
default:
return WebContentFormat.Default;
}
}
}
【问题讨论】:
标签: json .net-core content-type asp.net-core-webapi