Esempio 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, IApplicationLifetime lifetime)
        {
            lifetime.ApplicationStarted.Register(() =>
            {
                NLogHelper.InfoLog("lifetime.ApplicationStarted.Register启动!!!");
            });
            lifetime.ApplicationStopping.Register(() =>
            {
                NLogHelper.InfoLog("lifetime.ApplicationStopping.Register结束中!!!");
            });
            lifetime.ApplicationStopped.Register(() =>
            {
                NLogHelper.InfoLog("lifetime.ApplicationStopped.Register结束了!!!");
            });

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

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

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }