// 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, InstallService installService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/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.UseResponseCompression(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(); //NLog env.ConfigureNLog("nlog.config"); LogManager.Configuration.Variables["connectionString"] = Configuration.GetConnectionString("DefaultConnection"); //初始化系统菜单,及参数 installService.Install(); }
static void Main(string[] args) { try { if (args != null && args.Any(x => x == "/i")) { InstallService.Install(App.Config.AppName); return; } if (args != null && args.Any(x => x == "/s")) { InstallService.TryStopService(App.Config.AppName); return; } if (Environment.UserInteractive) { var app = new App(); app.Run().Wait(); } else { ServiceBase.Run(new Program()); } } catch (Exception ex) { File.AppendAllText(Path.Combine("C:\\", "failedToStart.txt"), ex.ToString()); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, InstallService installService) { 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.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); //NLog 数据库连接 LogManager.Configuration.FindTargetByName <DatabaseTarget>("db").ConnectionString = Configuration.GetConnectionString("DefaultConnection"); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapControllerRoute( name: "areas", pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); }); //初始化系统菜单,及参数 installService.Install(); }
/// <summary> /// Defines the method that starts the installation. /// </summary> /// <param name="obj"></param> private void InstallAppExecute(object obj) { installService.Install(); }