// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // (1) - Dependency Inyection DependencyInjectionConfig.Register(services); // (2) - AutoMapper Configuration AutoMapperConfig.Register(services); // (3) - Swagger Configuration SwaggerConfig.Register(services); // (4) - Setting Configuration AppSettingsConfig.Register(services, _env, Configuration); // (5) - services.AddControllers(); // (6) - Filters configurations FiltersConfig.Register(services); }
protected void ConfigureApp(IContainer container, IAppBuilder app) { HttpConfiguration = new HttpConfiguration { DependencyResolver = new AutofacWebApiDependencyResolver(container) }; HttpConfiguration.Formatters.Clear(); HttpConfiguration.Formatters.Add(new JsonMediaTypeFormatter()); HttpConfiguration.Formatters.JsonFormatter.SerializerSettings = new Newtonsoft.Json.JsonSerializerSettings(); //HttpConfiguration.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/octet-stream")); app.UseAutofacMiddleware(container); app.UseAutofacWebApi(HttpConfiguration); //ConfigureOAuth(app); RouteConfig.Register(HttpConfiguration); FiltersConfig.Register(HttpConfiguration); app.UseCors(CorsOptions.AllowAll); app.UseWebApi(HttpConfiguration); app.Use <GlobalExceptionMiddleware>(); }