【发布时间】:2015-06-20 03:10:50
【问题描述】:
我正在为 WebApi 使用 ASP.net 帮助页面。在我的一些响应格式示例中,我收到了与格式化程序有关的错误。我查看了各种教程,它们似乎都展示了如何覆盖 form-url-encoded 格式。我没有找到任何可以覆盖其他格式的东西:
应用程序/json、文本/json、文本/html、应用程序/xml、文本/xml
为了设置我使用的特定类型的样本
config.SetSampleForType("MessageGoesHere", new
MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(TypeGoesHere));
这有助于为表单 urlencoded 响应格式设置示例。我尝试用 application/json 或其他示例之一替换 MediaTypeHeader 值,但没有效果。
我的问题:我如何设置响应格式的示例,而不是 ASP.net 帮助页面上的 form-urlencoded?
【问题讨论】:
标签: c# asp.net-mvc asp.net-web-api