public static void Register(HttpConfiguration config) { // Web API configuration and services config.Formatters.Clear(); config.Formatters.Add(new JsonMediaTypeFormatter { SerializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, ContractResolver = new DefaultContractResolver { IgnoreSerializableAttribute = true } } }); config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(SimpleInjectorContainer.Build()); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
protected void Application_Start() { DependencyResolver.SetResolver( new SimpleInjectorDependencyResolver(SimpleInjectorContainer.Build())); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); // JS a CSS bundly BundleConfig.RegisterBundles(BundleTable.Bundles); RouteConfig.RegisterRoutes(RouteTable.Routes); // SimpleWebInjector var container = SimpleInjectorContainer.Build(GlobalConfiguration.Configuration); DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container)); Log.Info("App start"); }
protected void Application_Start() { GlobalConfiguration.Configure(config => config.Register(new SimpleInjectorWebApiDependencyResolver(SimpleInjectorContainer.Build()))); }