Moh*_*med 1 .net c# asp.net asp.net-mvc asp.net-web-api
在我的web api应用程序中,我接受Application/Json mediatype作为请求.因此,我希望自定义帮助页面以删除其他格式,例如application/xml,text/xml,application/x-www-form-urlencoded等.任何帮助都非常明显.
根据ASP.NET Web API中的JSON和XML序列化,这种方法是从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);
}
Run Code Online (Sandbox Code Playgroud)