Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews()
            .AddJsonOptions(options => ConfigureJsonSerializer(options.JsonSerializerOptions));;

            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp";
            });

            services.AddTransient <ApplicationUserManager>();
            services.AddTransient <ApplicationSignInManager>();

            services.AddDbContext <ChatDbContext>(options =>
            {
                options.UseSqlServer(
                    Configuration.GetConnectionString(ChatDbContext.ConnectionString));
            });

            // register it
            services.AddScoped <IUserClaimsPrincipalFactory <ApplicationUser>, AppClaimsPrincipalFactory>();

            services.AddIdentity <ApplicationUser, ApplicationRole>(opts =>
            {
                opts.Password.RequiredLength         = 5;
                opts.Password.RequireNonAlphanumeric = false;
                opts.Password.RequireLowercase       = false;
                opts.Password.RequireUppercase       = false;
                opts.Password.RequireDigit           = false;
            }).AddEntityFrameworkStores <ChatDbContext>()
            .AddDefaultTokenProviders();

            SwaggerConfiguration.ConfigureSwagger(services, new List <string>
            {
            });


            services.AddSignalR().AddJsonProtocol(options => {
                ConfigureJsonSerializer(options.PayloadSerializerOptions);
            });

            services.AddHangfire(x => x.UseSqlServerStorage(Configuration.GetConnectionString(ChatDbContext.ConnectionString)));

            //Установка приложения
            Croco.SetCrocoApplication(services);
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews().AddRazorRuntimeCompilation();

            services.Configure <FormOptions>(options =>
            {
                options.MultipartBodyLengthLimit = int.MaxValue;      // In case of multipart
                options.ValueCountLimit          = 200;               // 200 items max
                options.ValueLengthLimit         = 1024 * 1024 * 100; // 100MB max len form data
            });

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddTransient <ApplicationUserManager>();
            services.AddTransient <ApplicationSignInManager>();

            services.AddDbContext <XdocDbContext>(options =>
            {
                options.UseSqlServer(
                    Configuration.GetConnectionString(XdocDbContext.ConnectionString));
            });

            // register it
            services.AddScoped <IUserClaimsPrincipalFactory <ApplicationUser>, AppClaimsPrincipalFactory>();

            services.AddIdentity <ApplicationUser, ApplicationRole>(opts =>
            {
                opts.Password.RequiredLength         = 5;
                opts.Password.RequireNonAlphanumeric = false;
                opts.Password.RequireLowercase       = false;
                opts.Password.RequireUppercase       = false;
                opts.Password.RequireDigit           = false;
            }).AddEntityFrameworkStores <XdocDbContext>()
            .AddDefaultTokenProviders();

            SwaggerConfiguration.ConfigureSwagger(services, new List <string>
            {
            });

            services.ConfigureApplicationCookie(options =>
            {
                options.ExpireTimeSpan    = TimeSpan.FromDays(5);
                options.Cookie.HttpOnly   = true;
                options.SlidingExpiration = true;
                options.LoginPath         = "/Account/Login";
                options.LogoutPath        = "/Account/Logout";
            });

            services.AddControllersWithViews().AddJsonOptions(options => ConfigureJsonSerializer(options.JsonSerializerOptions));
            services.AddRazorPages();

            services.AddSignalR().AddJsonProtocol(options => {
                ConfigureJsonSerializer(options.PayloadSerializerOptions);
            });

            services.AddHttpContextAccessor();
            services.TryAddSingleton <IActionContextAccessor, ActionContextAccessor>();

            services.AddHangfire(x => x.UseSqlServerStorage(Configuration.GetConnectionString(XdocDbContext.ConnectionString)));

            //Установка приложения
            Croco.SetCrocoApplication(services);
        }
 public CrocoTest()
 {
     _croco = new Croco();
 }