Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            _platformInitializer.ConfigureServices(services);

            var connectionString = Configuration["ConnectionStrings:DefaultConnection"];

            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.AddDbContext <ApplicationContext>(options =>
                                                       options.UseSqlServer(Configuration.GetConnectionString("IdentityConnection")));

            services.AddIdentity <User, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationContext>();

            services.AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.ReferenceLoopHandling =
                    Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            });
        }
Beispiel #2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     _platformInitializer.ConfigureServices(services);
     services.AddMvc(options =>
     {
         options.Filters.Add(new ProducesAttribute("application/xml"));
     })
     .AddXmlSerializerFormatters()
     .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
 }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            _platformInitializer.ConfigureServices(services);

            var connectionString = Configuration["ConnectionStrings:DefaultConnection"];

            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.AddHangfire(config =>
            {
                config.UseSqlServerStorage(connectionString);
            });

            services.AddDbContext <ApplicationContext>(options =>
                                                       options.UseSqlServer(Configuration.GetConnectionString("IdentityConnection")));

            services.AddIdentity <User, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationContext>();

            // add signalr service
            services.AddSignalR().AddHubOptions <NewsHub>(option =>
            {
                option.KeepAliveInterval = System.TimeSpan.FromMinutes(10);
                option.HandshakeTimeout  = System.TimeSpan.FromMinutes(10);
            });

            services.AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.ReferenceLoopHandling =
                    Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            });
        }