CreateDefaultBuilder方法都做了什么?
當(dāng)我們創(chuàng)建好一個新的ASP.NET Core Web應(yīng)用時,系統(tǒng)會使用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的有參數(shù)版本,則還會通過命令行參數(shù)來初始化IConfiguration。
以上內(nèi)容來源于官方文檔:microsoft.aspnetcore.webhost.createdefaultbuilder

浙公網(wǎng)安備 33010602011771號