Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.AddDistributedMemoryCache();

            services.AddSession(options =>
            {
                options.IdleTimeout        = TimeSpan.FromHours(24);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
                options.Cookie.Name        = "QLSuaxe";
                services.AddHttpContextAccessor();
                services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            });
            services.AddDbContext <APPDbContext>(options =>
                                                 options.UseSqlServer(Configuration.GetConnectionString("connectionString"),
                                                                      sqlServerOptionsAction: sqlOptions =>
            {
                sqlOptions.EnableRetryOnFailure(
                    maxRetryCount: 1000,
                    maxRetryDelay: TimeSpan.FromSeconds(30),
                    errorNumbersToAdd: null)
                .CommandTimeout(30).UseRowNumberForPaging();
            }), ServiceLifetime.Transient);
            services.AddControllers();
            IOCConfig.Register(services, Configuration);
        }
Пример #2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     IOCConfig.Register();
 }
Пример #3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
     services.AddDbContext <DoAnDbContext>(options =>
                                           options.UseSqlServer(Configuration.GetConnectionString("connectionString"),
                                                                sqlServerOptionsAction: sqlOptions =>
     {
         sqlOptions.EnableRetryOnFailure(
             maxRetryCount: 1000,
             maxRetryDelay: TimeSpan.FromSeconds(30),
             errorNumbersToAdd: null)
         .CommandTimeout(30).UseRowNumberForPaging();
     }), ServiceLifetime.Transient);
     services.AddControllers();
     services.AddMemoryCache();
     IOCConfig.Register(services, Configuration);
 }