Created
February 12, 2018 15:20
-
-
Save jglozano/ad93027daedcc2925492cb6c3a6a0eca to your computer and use it in GitHub Desktop.
Browser JSON Formatter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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