예제 #1
0
파일: Startup.cs 프로젝트: markayby/Portal
        public void ConfigureServices(IServiceCollection services)
        {
            // DIConfiguration.Config(services, Configuration);
            DbConfiguration.Config(services, Configuration);
            AuthConfiguration.Config(services);

            services.AddAntiforgery(opt =>
            {
                opt.HeaderName      = "X-XSRF-TOKEN";
                opt.Cookie.Name     = "XSRF-TOKEN";
                opt.Cookie.HttpOnly = true;
                opt.Cookie.Path     = "/";
            });

            services.AddMemoryCache();
            services.AddDistributedMemoryCache();
            services.AddSession(opt => { opt.IdleTimeout = TimeSpan.FromDays(1); });

            services.AddLocalization(options => options.ResourcesPath = "Resources");
            services.AddRouting(options => options.LowercaseUrls      = true);
            services.AddMvc(
                options =>
            {
                options.ModelMetadataDetailsProviders.Add(
                    new CustomValidationMetadataProvider("Portal.SiteResources", typeof(SiteResources)));
            }
                )
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new DefaultContractResolver
                {
                    NamingStrategy = new SnakeCaseNamingStrategy()
                };
            })
            .AddDataAnnotationsLocalization()
            .AddViewLocalization();

            services.AddAutoMapper();

//            services.Configure<ApiBehaviorOptions>(options =>
//            {
//                options.SuppressModelStateInvalidFilter = true;
//                options.SuppressConsumesConstraintForFormFileParameters = true;
//            });
        }