ABP.IO WEB應用程式框架 取得環境名稱
簡介下 Domain 取得環境名稱
結論
簡介
有時,在創建一個應用程序時,我們需要獲得當前的主機環境,並根據該環境採取相應的行動。
在這種情況下,我們可以在最終的應用程序中使用一些服務,
如由.NET提供的 IWebHostEnvironment 或 IWebAssemblyHostEnvironment。
然而,我們不能在類庫中使用這些服務,而類庫是由最終的應用程序使用的。
ABP框架提供了IAbpHostEnvironment服務,它允許你隨時獲得當前的環境名稱。
IAbpHostEnvironment被ABP框架在幾個地方使用,以執行環境的特定動作。
例如,ABP框架在開發環境上減少一些服務的緩存時間。
IAbpHostEnvironment通過以下順序獲得當前環境名稱:
獲取並設置環境名稱,如果它在
AbpApplicationCreationOptions中被指定。如果環境名稱沒有在
AbpApplicationCreationOptions中指定, 則嘗試從IWebHostEnvironment或IWebAssemblyHostEnvironment服務 為 ASP.NET Core & Blazor WASM 應用程序獲取環境名稱。如果環境名稱未被指定或無法從服務中獲得,則將環境名稱設置為生產(Production)。
What's New with ABP Framework 7.1?
In this section, I will introduce some major features released in this version. In addition to these features, so many enhancements have been made in this version too.
Here is a brief list of the titles explained in the next sections:
Blazor WASM option added to Application Single Layer Startup Template
Introducing the
IHasEntityVersioninterface andEntitySynchronizerbase classIntroducing the
DeleteDirectAsyncmethod for theIRepositoryinterfaceIntroducing the
IAbpHostEnvironmentinterfaceImprovements on the eShopOnAbp project
Others
同場加映
取得 appsettings 設定值
參照
Application Startup | Documentation Center | ABP.IO

PS5
回首頁
本文章從點部落遷移至 Writerside