コード例 #1
0
ファイル: Startup.cs プロジェクト: mario102/EmployeeDirectory
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MsSqlServerClient sqlServerClient)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            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.UseRequestLogging();                               //используем этот компонент для логирования http запросов к серверу

            var Sqlconnection = sqlServerClient.SqlConnection;     //получаем наш connection

            DataBaseInitializer.CreateProfileTable(Sqlconnection); //создаём табличку, если её нет
            DataBaseInitializer.InitializeProfiles(Sqlconnection); //инициализируем табличку начальными данными, если данных в таблице нет


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

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action}/{part}",
                    defaults: new { controller = "Home", action = "Index", part = 1 });
            });
        }