CreateDefaultBuilder方法都做了什么?


當我們創建好一個新的ASP.NET Core Web應用時,系統會使用CreateDefaultBuilder方法,這個方法完成了以下操作:

  • use Kestrel as the web server and configure it using the application's configuration providers
  • set the ContentRootPath to the result of GetCurrentDirectory()
  • load IConfiguration from 'appsettings.json' and 'appsettings.[EnvironmentName].json'
  • load IConfiguration from User Secrets when EnvironmentName is 'Development' using the entry assembly,
  • load IConfiguration from environment variables
  • configure the ILoggerFactory to log to the console and debug output
  • and enable IIS integration

如果使用了CreateDefaultBuilder的有參數版本,則還會通過命令行參數來初始化IConfiguration。

以上內容來源於官方文檔:microsoft.aspnetcore.webhost.createdefaultbuilder


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM