Created
February 24, 2017 00:29
-
-
Save ksysiekj/7863630118a6e29b5ccd861596af9634 to your computer and use it in GitHub Desktop.
This file contains 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 static class WebApiConfig | |
{ | |
public static void Register(HttpConfiguration config) | |
{ | |
// Web API configuration and services | |
// Configure Web API to use only bearer token authentication. | |
config.SuppressDefaultHostAuthentication(); | |
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); | |
config.ConfigureJSONFormatter(); | |
// Web API routes | |
config.MapHttpAttributeRoutes(); | |
config.Routes.MapHttpRoute( | |
name: "DefaultApi", | |
routeTemplate: "api/{controller}/{id}", | |
defaults: new { id = RouteParameter.Optional } | |
); | |
} | |
private static void ConfigureJSONFormatter(this HttpConfiguration config) | |
{ | |
// remove Json.NET | |
// config.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings | |
// { | |
// ContractResolver = new CamelCasePropertyNamesContractResolver(), | |
// NullValueHandling = NullValueHandling.Ignore, | |
// DateFormatHandling = DateFormatHandling.IsoDateFormat | |
// }; | |
// use Jil | |
config.Formatters.RemoveAt(0); | |
config.Formatters.Insert(0, new JilMediaTypeFormatter()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment