Skip to content

Instantly share code, notes, and snippets.

@walkingriver walkingriver/Startup.cs
Last active Aug 29, 2015

What would you like to do?
My Default Startup Class for OWIN WebAPI apps.
/// <summary>
/// Default Startup Class for OWIN WebAPI apps
/// </summary>
/// <remarks>
/// Requires the following NuGet Packages to be installed:
/// - Install-Package Microsoft.AspNet.WebApi.Owin
/// - Install-Package Microsoft.AspNet.WebApi.WebHost (If IIS-hosted)
/// </remarks>
public class Startup
public void Configuration(IAppBuilder app)
var config = new HttpConfiguration();
private static void ConfigureRoutes(HttpConfiguration config)
// I only want Attribute Routing
// For now, let's turn on all error details.
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
private static void ConfigureJson(HttpConfiguration config)
var formatters = config.Formatters;
var jsonFormatter = formatters.JsonFormatter;
// This lets us get JSON as the default in the browser
jsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
// This camelCases our JSON
var settings = jsonFormatter.SerializerSettings;
settings.Formatting = Formatting.Indented;
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.