NopCommerce采用的asp.net MVC架构,根据asp.net MVC架构模板,应有App_Start文件夹,里面包含路由等网站启动的相应处理程序,而NopCommerce启动处理理程序应用的Global.asax
protected void Application_Start()
{
//most of API providers require TLS 1.2 nowadays
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
//disable "X-AspNetMvc-Version" header name
MvcHandler.DisableMvcResponseHeader = true;
//initialize engine context
EngineContext.Initialize(false);
bool databaseInstalled = DataSettingsHelper.DatabaseIsInstalled();
if (databaseInstalled)
{
//remove all view engines
ViewEngines.Engines.Clear();
//except the themeable razor view engine we use
ViewEngines.Engines.Add(new ThemeableRazorViewEngine());
}
//Add some functionality on top of the default ModelMetadataProvider
ModelMetadataProviders.Current = new NopMetadataProvider();
//Registering some regular mvc stuff
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
//fluent validation
DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new NopValidatorFactory()));
if (databaseInstalled)
{
//start scheduled tasks
TaskManager.Instance.Initialize();
TaskManager.Instance.Start();
//miniprofiler
if (EngineContext.Current.Resolve<StoreInformationSettings>().DisplayMiniProfilerInPublicStore)
{
GlobalFilters.Filters.Add(new ProfilingActionFilter());
}
//log application start
try
{
//log
var logger = EngineContext.Current.Resolve<ILogger>();
logger.Information("Application started", null, null);
}
catch (Exception)
{
//don't throw new exception if occurs
}
}
}
标签:启动,EngineContext,Current,Start,Add,NopCommerce,new From: https://www.cnblogs.com/5x19/p/16916328.html