更新时间:2022-05-19 21:50:59
在常规.NET世界中,我们可以选择将设置保存在web.config或app.config文件中.但是在.NET Core中,您可以选择将它们保存在其他几个位置,例如appsettings.json
,appsettings.<Environment>.json
和secrets.json
中.
In regular .NET world, we have option to save settings in web.config or in app.config file. But in .NET Core, you have option to save them in few other locations like appsettings.json
, appsettings.<Environment>.json
and in secrets.json
.
未将设置保存在web.config文件中的主要原因之一是为了避免将设置检入到回购中.默认情况下,appsettings.json
文件被回购客户端忽略.
One of the main reason settings are not saved in web.config file is, to avoid settings getting checked-into repo. By default appsettings.json
file are ignored by repo clients.
正如柯克所说, dotnet -cli 根据csproj设置自动创建此web.config
.
As Kirk said, the dotnet-cli automatically creates this web.config
based on the the csproj settings.