搜索

NopCommerce的启动


发布时间: 2022-11-24 21:54:00    浏览次数:32 次

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
}
}
}

 

免责声明 NopCommerce的启动,资源类别:文本, 浏览次数:32 次, 文件大小:-- , 由本站蜘蛛搜索收录2022-11-24 09:54:00。此页面由程序自动采集,只作交流和学习使用,本站不储存任何资源文件,如有侵权内容请联系我们举报删除, 感谢您对本站的支持。 原文链接:https://www.cnblogs.com/5x19/p/16916328.html