public void AddXncfDatabaseModule(IServiceCollection services)
        {
            //DOT REMOVE OR MODIFY THIS LINE 请勿移除或修改本行 - Entities Point
            //ex. services.AddScoped(typeof(Color));

#if RELEASE
            //生成之前先注释一下代码

            services.Configure <StaticResourceSetting>(FileServerConfiguration.GetSection("FileServer:StaticResource"));

            //路由小写
            services.AddRouting(options => { options.LowercaseUrls = true; });
            //配置上传文件大小限制(详细信息:FormOptions)
            services.Configure <FormOptions>(options =>
            {
                options.MultipartBodyLengthLimit = FileServerConfiguration.GetValue <int>("FileServer:StaticResource:MaxSize") * 1024 * 1024;
            });
            //跨域
            var domains        = FileServerConfiguration.GetSection("Cors:Domain").Get <string[]>();
            var allowedOrigins = new HashSet <string>(domains, StringComparer.OrdinalIgnoreCase);
            services.AddCors(options => options.AddDefaultPolicy(builder =>
            {
                //builder.AllowCredentials();
                builder.SetIsOriginAllowed(origin => allowedOrigins.Contains(new Uri(origin).Host));
            }));
#endif
        }
Example #2
0
 private static void RegisterServices(IServiceCollection services)
 {
     FileServerConfiguration.RegisterServices(services);
 }