コード例 #1
0
ファイル: Startup.cs プロジェクト: VEAmit/NationalNeon
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDistributedMemoryCache(); // Adds a default in-memory implementation of IDistributedCache
            services.AddSession();
            services.AddMvc();
            services.AddSingleton <IConfiguration>(Configuration);
            //services.AddScoped<MXEntities>(_ =>
            //new MXEntities());
            //services.AddDbContext<MXEntities>(options =>
            //options.UseSqlServer(Configuration.GetConnectionString("MXEntities")));
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("MXEntities")));

            services.AddAuthentication(options =>
            {
                options.DefaultSignInScheme       = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = CookieAuthenticationDefaults.AuthenticationScheme;
            }).AddCookie(options => { options.LoginPath = "/Login"; });
            services.AddMvc().AddRazorPagesOptions(options =>
            {
                options.Conventions.AuthorizeFolder("/");
                options.Conventions.AllowAnonymousToPage("/Login");
            });

            Bindings.AddBindings(services);
            Mapping.RegisterBusinessMap();
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: VEAmit/NationalNeon
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddSingleton <IConfiguration>(Configuration);
     services.AddMvc();
     services.AddSession();
     services.AddDistributedMemoryCache();
     services.AddDbContext <ApplicationDbContext>(options =>
                                                  options.UseSqlServer(Configuration.GetConnectionString("MXEntities")));
     Bindings.AddBindings(services);
 }