예제 #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    "default",
                    "{controller}/{action}",
                    new { Controller = "Home", Action = nameof(HomeController.Index) });
            });

            app.MapWhen(
                context =>
            {
                return(!context.Request.Path.Value.ToLower().StartsWith("/api"));
            },
                builder =>
            {
                builder.UseMvc(routes =>
                {
                    routes.MapSpaFallbackRoute(
                        "spa",
                        new { Controller = "Home", Action = nameof(HomeController.Index) });
                });
            });

            AppConfigurator.InitDbContext(Configuration);
        }