protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); FluentValidationModelValidatorProvider.Configure(); IUnityContainer container = new UnityContainer(); UnityRegistrar.Register(container); AutoMapperInitializer.Initialise(); ControllerBuilder.Current.SetControllerFactory(new UnityControllerFactory(container)); DummyDataCreator.PopulateRepository(); }
public static void Register(HttpConfiguration config) { // Web API configuration and services // Configure the Dependency Resolver var registrar = new UnityRegistrar(); var container = new UnityContainer(); container = registrar.Register(container); config.DependencyResolver = new UnityResolver(container); // Configure Web API to use only bearer token authentication. config.SuppressDefaultHostAuthentication(); config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }