Example #1
0
        protected void Application_Start()
        {
            // added bootstrapping for simpleinjector, register in DependencyConfig
            var container = new Container();

            container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            DependencyConfig.RegisterSimpleInjector(container);

            container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
            container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            //container.Verify();

            GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
            DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));

            MvcHandler.DisableMvcResponseHeader = true;
            ModelBinders.Binders.DefaultBinder  = new SmartBinder();
            ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
            ModelBinders.Binders.Add(typeof(decimal?), new DecimalModelBinder());
            ModelBinders.Binders.Add(typeof(int?), new NullableIntModelBinder());
            ModelMetadataProviders.Current = new ModelViewMetadataProvider();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            RouteTable.Routes.RouteExistingFiles = true;
            HttpRuntime.Cache.Remove("BuildDate");

            //Remove and JsonValueProviderFactory and add JsonNetValueProviderFactory
            ValueProviderFactories.Factories.Remove(ValueProviderFactories.Factories.OfType <JsonValueProviderFactory>().FirstOrDefault());
            ValueProviderFactories.Factories.Add(new JsonNetValueProviderFactory());

            //            MiniProfiler.Settings.Results_List_Authorize = IsAuthorizedToViewProfiler;
            //            MiniProfiler.Settings.Results_Authorize = IsAuthorizedToViewProfiler;
        }
Example #2
0
        protected void Application_Start()
        {
            DependencyConfig.RegisterSimpleInjector();

            MvcHandler.DisableMvcResponseHeader = true;
            ModelBinders.Binders.DefaultBinder  = new SmartBinder();
            ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
            ModelBinders.Binders.Add(typeof(decimal?), new DecimalModelBinder());
            ModelBinders.Binders.Add(typeof(int?), new NullableIntModelBinder());
            ModelMetadataProviders.Current = new ModelViewMetadataProvider();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            RouteTable.Routes.RouteExistingFiles = true;
            HttpRuntime.Cache.Remove("BuildDate");

            ValueProviderFactories.Factories.Remove(ValueProviderFactories.Factories.OfType <JsonValueProviderFactory>().FirstOrDefault());
            ValueProviderFactories.Factories.Add(new JsonNetValueProviderFactory());
            if (Util.IsDebug())
            {
                DbUtil.Migrate();
            }
            var command = ConfigurationManager.AppSettings["StartupCommand"];

            if (command.HasValue())
            {
                Process.Start("cmd.exe", $"/c {command}");
            }
        }