Exemplo n.º 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, DatabaseSeed databaseSeeder)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            loggerFactory.AddFile("Logs/Hooxit-{Date}.txt");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseAuthentication();

            app.Use((context, next) =>
            {
                var identityName = context.User.Identity.Name;

                if (identityName != null)
                {
                    UserInfo.UserName = identityName;
                }

                return(next());
            });

            app.UseStaticFiles();
            app.UseSession();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "Profile",
                    template: "Profile/{*username}",
                    defaults: new { controller = "Profile", action = "Profile" });

                routes.MapRoute(
                    name: "Account",
                    template: "{area:exists}/{controller=Account}/{action=Index}/{id?}");
            });

            databaseSeeder.SeedDB(app);
        }