Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                using (var context = new KompaniInfoContext(app.ApplicationServices.GetRequiredService <DbContextOptions <KompaniInfoContext> >()))
                {
                    context.Database.Migrate();
                }
            }
            var supportedCultures = new[] { new CultureInfo("sv-SE") };

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new Microsoft.AspNetCore.Localization.RequestCulture("sv-SE"),
                SupportedCultures     = supportedCultures,
                SupportedUICultures   = supportedCultures
            });

            app.UseStaticFiles();
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme  = "Cookie",
                LoginPath             = new PathString("/Login/Index/"),
                AccessDeniedPath      = new PathString("/Login/Forbidden/"),
                AutomaticAuthenticate = true,
                AutomaticChallenge    = true
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "sidor",
                    template: "Sida/{id:int}",
                    defaults: new { controller = "Sida", action = "Index" });
                routes.MapRoute(
                    name: "poster",
                    template: "Post/{id:int}",
                    defaults: new { controller = "Post", action = "Index" });
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Beispiel #2
0
 public FilRepository(KompaniInfoContext context)
 {
     _context = context;
 }