gpt4 book ai didi

c# - 自定义 web api 帮助页面以删除请求格式

转载 作者:太空宇宙 更新时间:2023-11-03 20:01:07 26 4
gpt4 key购买 nike

在我的 web api 应用程序中,我接受 Application/Json mediatype 作为请求。所以我想自定义帮助页面以删除其他格式,例如 application/xml、text/xml、application/x-www-form-urlencoded 等。任何帮助都非常有用。

最佳答案

根据 JSON and XML Serialization in ASP.NET Web API方法是从 Global.asax 中定义的 Application_Start 方法调用它。

void ConfigureApi(HttpConfiguration config)
{
// Remove the JSON formatter
config.Formatters.Remove(config.Formatters.JsonFormatter);

// or

// Remove the XML formatter
config.Formatters.Remove(config.Formatters.XmlFormatter);
}

关于c# - 自定义 web api 帮助页面以删除请求格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28185776/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com