Skip to content

Instantly share code, notes, and snippets.

@matejskubic
Forked from tugberkugurlu/onlyJSON.cs
Created August 23, 2012 19:31
Show Gist options
  • Save matejskubic/3440636 to your computer and use it in GitHub Desktop.
Save matejskubic/3440636 to your computer and use it in GitHub Desktop.
public static void Configure(HttpConfiguration config) {
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.Formatters.Remove(config.Formatters.FormUrlEncodedFormatter);
// From DefaultContentNegotiator class:
// If ExcludeMatchOnTypeOnly is true then we don't match on type only which means
// that we return null if we can't match on anything in the request. This is useful
// for generating 406 (Not Acceptable) status codes.
config.Services.Replace(
typeof(IContentNegotiator),
new DefaultContentNegotiator(excludeMatchOnTypeOnly: true)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment