Пример #1
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            OAuthConfig.ConfigureOAuth(app);

            HandlersConfig.RegisterGlobalHandlers(config);

            RoutesConfig.Register(config);

            FormattersConfig.Configure(config);

            FiltersConfig.RegisterGlobalFilters(config);

            BindersConfig.RegisterGlobalBinders(config);

            TracingConfig.Configure();

            TokenConfig.ConfigureOAuthTokenConsumption(app);

            AutoMapperConfig.ConfigMappers();

            app.UseCors(CorsOptions.AllowAll);

            app.UseNinjectMiddleware(IoC.CreateKernel);

            app.UseNinjectWebApi(config);
        }
Пример #2
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            AreaRegistration.RegisterAllAreas();
            UnityConfig.RegisterComponents();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // *************
            // Model binders
            // *************
            BindersConfig.RegisterBinders();

            // **************
            // IoC initialise
            // **************

            // **********
            // Automapper
            // **********
            AutoMapperConfig.RegisterMappers();

            //ControllerBuilder.Current.SetControllerFactory(typeof(CustomControllerFactory));
        }
Пример #3
0
        private static void AppStart()
        {
            ////Scripts.DefaultTagFormat = @"<script src=""{0}"" async></script>";
            Styles.DefaultTagFormat = @"<link href=""{0}"" rel=""stylesheet"" async/>";

            MvcHandler.DisableMvcResponseHeader = true;

            AreaRegistration.RegisterAllAreas();

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine {
                FileExtensions = new[] { "cshtml" }
            });

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            BundleTable.EnableOptimizations = false;
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            BindersConfig.RegisterModelBinders(ModelBinders.Binders);

            // Create controller with localization - before model bind
            ControllerBuilder.Current.SetControllerFactory(
                new DefaultControllerFactory(new LocalizationControllerActivator()));

            // Remove and JsonValueProviderFactory and add JsonDotNetValueProviderFactory
            if (ConfigurationReader.ChangeDefaultJsonValueProviderFactory)
            {
                ValueProviderFactories.Factories.Remove(
                    ValueProviderFactories
                    .Factories.OfType <JsonValueProviderFactory>().FirstOrDefault());
                ValueProviderFactories.Factories.Add(new JsonDotNetValueProviderFactory());
            }

            // Add client validation localization - for this moment is only for DateType and RequiredAttribute
            ClientDataTypeModelValidatorProvider.ResourceClassKey = "Resource";
            DefaultModelBinder.ResourceClassKey = "Resource";

            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
            DataAnnotationsModelValidatorProvider.RegisterAdapter(
                typeof(RequiredAttribute),
                typeof(LocalizationRequiredAttributeAdapter));

            AntiForgeryConfig.SuppressIdentityHeuristicChecks = true;

            ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true;

            // Changed default model binder - may to use custom property binder as attribute in view model. Example is decrypting of ids
            ModelBinders.Binders.DefaultBinder = new ExtendedModelBinder();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // If you have enabled SSL. Uncomment this line to ensure that the Anti-Forgery
            // cookie requires SSL to be sent across the wire.
            AntiForgeryConfig.RequireSsl = ConfigurationReader.AntiForgeryConfigRequireSsl;

            // Rename the Anti-Forgery cookie from "__RequestVerificationToken" to "f".
            // This adds a little security through obscurity and also saves sending a
            // few characters over the wire.
            AntiForgeryConfig.CookieName = "f";
        }