/// <summary> /// Application startup. /// </summary> protected void Application_Start() { XmlConfigurator.Configure(); AutoMapper.Mapper.Initialize(c => { c.AddProfile<ModelMappingProfile>(); }); // Container injectablePropertiesCache = new TypePropertyDescriptorCache(); container = InitializeContainer(); // MVC ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new RazorViewEngine()); ModelBinders.Binders.DefaultBinder = new SharpModelBinder(); FilterProviders.Providers.InstallMvcFilterProvider(container, injectablePropertiesCache); ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container)); AreaRegistration.RegisterAllAreas(); // WebAPI GlobalConfiguration.Configure(cfg => WebApiConfig.Register(cfg, container, injectablePropertiesCache)); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
public static void Register(HttpConfiguration config, IWindsorContainer container, TypePropertyDescriptorCache propertyDescriptorCache) { // Web API configuration and services config.UseWindsor(container, propertyDescriptorCache); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }