【发布时间】:2020-09-19 00:29:58
【问题描述】:
我使用 Visualstudio 2019 创建默认的 Asp.net 核心 Web API 解决方案。
更改 services.AddControllers();到 services.AddControllers().AddXmlSerializerFormatters();
将获取请求发送至https://localhost:xxxxx/weatherforecast。 我得到以下回应
<ArrayOfWeatherForecast xmlns:xsi="http://www.w3.org.....>
<WeatherForecast>
...
</WeatherForecast>
......
</ArrayOfWeatherForecast>
但我真的很想得到这样的回应
<WeatherForecasts>
<WeatherForecast>
...
</WeatherForecast>
......
</WeatherForecasts>
我找到了一些关于从 asp.net 中删除 arrayof 的答案。 请帮我。如何在 asp.net core 中做到这一点。
【问题讨论】:
-
我认为这里有一些示例代码可以提供帮助。
标签: c# xml asp.net-core-webapi