12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using CZFW.Core;
- using CZFW.Framework.Logic;
- using CZFW.Framework.Model;
- using CZKJ.GBRS2.WebMVC.AppCode;
- using log4net;
- using log4net.Config;
- using log4net.Repository;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- using System.IO;
- using System.Text.Encodings.Web;
- using System.Text.Unicode;
- namespace CZKJ.GBRS2.WebMVC
- {
- public class Startup
- {
- public static ILoggerRepository repository { get; set; }
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- ConfigHelper.Configs = Configuration;
- repository = LogManager.CreateRepository("NetCoreRepository");
- XmlConfigurator.Configure(repository, new FileInfo("log4net.config"));
- InitRepository.loggerRepository = repository;
- }
- public IConfiguration Configuration { get; }
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddMvc(o => o.Filters.Add(typeof(GlobalExceptions)));
- services.AddDbContext<CZDbContext>();
- services.AddSession();
- services.ConfigServies();
- services.AddLogging();
- services.AddMemoryCache();
- services.AddLogging();
- services.ConfigureFrameworkServices();
- services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
-
- CZHttpContext.ServiceProvider = services.BuildServiceProvider();
- }
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger)
- {
- logger.AddLog4Net();
- app.UseSession();
- if (env.IsDevelopment())
- {
- app.UseBrowserLink();
- app.UseDeveloperExceptionPage();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- }
- //logger.AddFile(Configuration.GetSection("FileLogging"));
- //logger.AddEventSourceLogger();
- app.UseStaticFiles();
- app.UseMvc(routes =>
- {
- routes.MapRoute(
- name: "areas",
- template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
- );
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
- });
- }
- }
- }
|