![](/img/trans.png)
[英]Is there any way to configure owin startup.cs to be run before global asax application start?
[英]Run a function just once in StartUp.cs After application Deployment
我正在開發 ASP.NET 核心 2.2 Web 應用程序。 我想在每次在 Startup.cs 文件中部署應用程序后只運行一次函數。
此功能會減慢應用程序的速度,因為它會對應用程序啟動進行一些繁重的檢查。 每次部署應用程序時,我只想運行一次。
這是代碼
SynapseCore.Services.Plugins.SiteContentDiscovery iCont = new SiteContentDiscovery();
_logger.LogInformation("Startup - Complete : SiteContentDiscovery", new object[0]);
SynapseCore.Shared.GlobalData.pluginList = pluginsInfoList;
_logger.LogInformation("Startup - Complete : pluginList", new object[0]);
iCont.SetPluginInfo(pluginsInfoList);
_logger.LogInformation("Startup - Complete : SetPluginInfo", new object[0]);
//The following function 'CheckDatabaseIntegrity' is to be run once after deployment.
iCont.CheckDatabaseIntegrity();
_logger.LogInformation("Startup - Complete : CheckDatabaseIntegrity", new object[0]);
iCont.CheckPluginStatus();
_logger.LogInformation("Startup - Complete : CheckPluginStatus", new object[0]);
PluginSiteComposedData composedData = iCont.CompileSiteDataList();
我已經調查過
Environment.GetEnvironmentVariables()
但似乎沒有我正在尋找的屬性。
我的問題是,如果應用程序在 IIS 上部署后第一次運行,我如何通過代碼檢測?
您可以簡單地存儲和檢查程序集版本。 如果它增加了,您可以假設您部署了一個新版本。
但是每次要部署新版本時,您還必須在項目屬性中增加它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.