Пример #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options => options.AddPolicy("free-policy", builder =>
            {
                builder.AllowAnyOrigin();
                builder.AllowAnyMethod();
                builder.AllowAnyHeader();
            }));
            services.Configure <FormOptions>(x =>
            {
                x.MemoryBufferThreshold        = int.MaxValue;
                x.MultipartBoundaryLengthLimit = int.MaxValue;
                x.MultipartHeadersLengthLimit  = int.MaxValue;
                x.ValueLengthLimit             = int.MaxValue;
                x.MultipartBodyLengthLimit     = int.MaxValue;
                x.MultipartHeadersCountLimit   = int.MaxValue;
            });
            services.AddControllers();

            services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultScheme             = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(options => JwtHelper.ConfigureJwtOptions(options));
            services.AddAuthorization();

            services.AddAutoMapper(typeof(MapperProfile));
            services.ConfigureContext(options =>
                                      options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddScoped <IAccountService, AccountService>();
            services.AddScoped <IFileService, FileService>();
            services.AddScoped <IUserService, UserService>();
            services.ConfigureDependencies();
        }