Skip to content

Instantly share code, notes, and snippets.

@jglozano
Created February 12, 2018 15:20
Show Gist options
  • Save jglozano/ad93027daedcc2925492cb6c3a6a0eca to your computer and use it in GitHub Desktop.
Save jglozano/ad93027daedcc2925492cb6c3a6a0eca to your computer and use it in GitHub Desktop.
Browser JSON Formatter
public class BrowserJsonFormatter : JsonMediaTypeFormatter
{
public BrowserJsonFormatter()
{
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
SerializerSettings.Formatting = Formatting.Indented;
}
public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, MediaTypeHeaderValue mediaType)
{
base.SetDefaultContentHeaders(type, headers, mediaType);
headers.ContentType = new MediaTypeHeaderValue("application/json");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment