protected void Application_Start() { FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); GlobalConfiguration.Configure(x => { x.MapHttpAttributeRoutes(); IocConfig.Register(x); x.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); x.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; x.Filters.Add(new ApiExceptionFilter()); }); IocConfig.AutofacDependencyResolver.ApplicationContainer.Resolve <ICacheAccessor>().InitialiseIfNecessaryAsync().Wait(); var fluentValidationModelValidatorProvider = new FluentValidationModelValidatorProvider(new AutofacValidatorFactory(IocConfig.AutofacDependencyResolver)); DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; fluentValidationModelValidatorProvider.AddImplicitRequiredValidator = false; ModelValidatorProviders.Providers.Add(fluentValidationModelValidatorProvider); FlushLogMessages(); ModelBinders.Binders.DefaultBinder = new DefaultModelBinderEx(); ValueProviderFactories.Factories.Add(new TokenValueProviderFactory()); MvcHandler.DisableMvcResponseHeader = true; }
protected void Application_Start() { #if DEBUG try { GetExternalSettings(); } catch (Exception e) { throw new UnauthorizedAccessException("Could not get external settings. This is probably because you haven't been issued the external settings file."); } #endif GlobalConfiguration.Configure(x => { x.MapHttpAttributeRoutes(); IocConfig.Register(x); x.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); x.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; x.Filters.Add(new ApiExceptionFilter()); }); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters, IocConfig.AutofacDependencyResolver.ApplicationContainer.Resolve <ExceptionHandler>()); RouteConfig.RegisterRoutes(RouteTable.Routes); IocConfig.AutofacDependencyResolver.ApplicationContainer.Resolve <ICacheAccessor>().InitialiseIfNecessaryAsync().Wait(); var fluentValidationModelValidatorProvider = new FluentValidationModelValidatorProvider(new AutofacValidatorFactory(IocConfig.AutofacDependencyResolver)); DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; fluentValidationModelValidatorProvider.AddImplicitRequiredValidator = false; ModelValidatorProviders.Providers.Add(fluentValidationModelValidatorProvider); var logger = IocConfig.AutofacDependencyResolver.ApplicationContainer.Resolve <IAzLogger>(); logger.ScheduleLogFlush(); logger.ScheduleLogPurge(); IocConfig.AutofacDependencyResolver.ApplicationContainer.Resolve <IExternalLookupService>(); ModelBinders.Binders.DefaultBinder = new DefaultModelBinderEx(); ValueProviderFactories.Factories.Add(new TokenValueProviderFactory()); MvcHandler.DisableMvcResponseHeader = true; }