protected void Application_Start() { // TODO: 防止出现sysUser not in context的错误 // new Infrastructure.Web.Domain.Entity.SysUser(); //initialize engine context // EngineContext.Initialize(false); bool databaseInstalled = true;// DataSettingsHelper.DatabaseIsInstalled(); if (databaseInstalled) { //remove all view engines ViewEngines.Engines.Clear(); //except the themeable razor view engine we use // ViewEngines.Engines.Add(new ThemeableRazorViewEngine()); ViewEngines.Engines.Add(new PluginRazorViewEngine()); } //Add some functionality on top of the default ModelMetadataProvider // ModelMetadataProviders.Current = new NopMetadataProvider(); //Registering some regular mvc stuff AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); MappingExtensions.MapperRegister(); Infrastructure.Web.Domain.Entity.ModelMap.MapperRegister(); //fluent validation // DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; // ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new NopValidatorFactory())); //start scheduled tasks if (databaseInstalled) { //modified by john var jobs = WebConfigurationManager.AppSettings["jobs"]; if (!string.IsNullOrEmpty(jobs)) { TaskManager.Instance.Initialize(jobs.Split(',')); TaskManager.Instance.Start(); } } //miniprofiler //if (databaseInstalled) //{ // if (EngineContext.Current.Resolve<StoreInformationSettings>().DisplayMiniProfilerInPublicStore) // { // GlobalFilters.Filters.Add(new ProfilingActionFilter()); // } //} //log application start //if (databaseInstalled) //{ // try // { // //log // var logger = EngineContext.Current.Resolve<ILogger>(); // logger.Info("Application started", null, null); // } // catch (Exception) // { // //don't throw new exception if occurs // } //} //AppDomain.CurrentDomain.DomainUnload += delegate { }; }