protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); //初始化数据库 //策略一:数据库不存在时重新创建数据库 //Database.SetInitializer<EFDbContext>(new CreateDatabaseIfNotExists<EFDbContext>()); //策略二:每次启动应用程序时创建数据库 //Database.SetInitializer<testContext>(new DropCreateDatabaseAlways<testContext>()); //策略三:模型更改时重新创建数据库 //Database.SetInitializer<testContext>(new DropCreateDatabaseIfModelChanges<testContext>()); //策略四:从不创建数据库 //Database.SetInitializer<EFDbContext>(null); DatabaseInitializer.Initialize(); //依赖注入 AutofacEngine.RegisterAutofac(); //AutoMapper注册 RegisterAutomapper.Excute(); //WebApi注册 GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddLogging(loggingBuilder => loggingBuilder.AddDebug()); RegisterAutomapper.Register(services, Configuration); RegisterDependencyInjectionModules.Register(services, Configuration); services.AddControllers(); }
public static void Main(string[] args) { LicenseManager.AddLicense("67;100-MASUIT", "809739091397182EC1ECEA8770EB4218"); RegisterAutomapper.Excute(); MyHub.Init(); CreateWebHostBuilder(args).Build().Run(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //AutoMapper映射初始化 RegisterAutomapper.Excute(); }
public static void Startup() { //移除aspx视图引擎 ViewEngines.Engines.RemoveAt(0); RegisterAutomapper.Excute(); using (new DataContext()) { } HangfireConfig.Register(); Registry reg = new Registry(); reg.Schedule(() => CollectRunningInfo.Start()).ToRunNow().AndEvery(5).Seconds(); //启动服务器监控任务 JobManager.Initialize(reg); //初始化定时器 }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //Autofac初始化 AutofacConfig.ConfigureContainer(); //Automapper RegisterAutomapper.Initialize(); }
public static void Startup() { //移除aspx视图引擎 ViewEngines.Engines.RemoveAt(0); LogManager.LogDirectory = LogManager.LogDirectory = AppDomain.CurrentDomain.BaseDirectory + @"App_Data\Logs\"; //设置日志目录 AutofacConfig.RegisterMVC(); RegisterAutomapper.Excute(); HangfireConfig.Register(); Registry reg = new Registry(); reg.Schedule(() => CollectRunningInfo.Start()).ToRunNow().AndEvery(5).Seconds(); JobManager.Initialize(reg);//初始化定时器 }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); //autofac注册 RegisterAutofacForSingle.RegisterAutofac(); //automapper注册 RegisterAutomapper.Excute(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } // Shows UseCors with named policy. app.UseCors("AllowSpecificOrigin"); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { // spa.UseReactDevelopmentServer(npmScript: "start"); spa.UseVueCli(npmScript: "dev", port: 8080); } }); RegisterAutomapper.Excute(); }