其他分享
首页 > 其他分享> > .Net Core WebApi文件配置内容(转)

.Net Core WebApi文件配置内容(转)

作者:互联网

ASP.NET Core launchsettings.json 文件

具体配置

 1 {
 2   "$schema": "http://json.schemastore.org/launchsettings.json",
 3   "iisSettings": {
 4     "windowsAuthentication": false,
 5     "anonymousAuthentication": true,
 6     "iisExpress": {
 7       "applicationUrl": "http://localhost:57596",
 8       "sslPort": 44392
 9     }
10   },
11   "profiles": {
12     "IIS Express": {
13       "commandName": "IISExpress",
14       "launchBrowser": true,
15       "launchUrl": "weatherforecast",
16       "environmentVariables": {
17         "ASPNETCORE_ENVIRONMENT": "Development"
18       }
19     },
20     "WebApiTest": {
21       "commandName": "Project",
22       "launchBrowser": true,
23       "launchUrl": "weatherforecast",
24       "applicationUrl": "https://localhost:5001;http://localhost:5000",
25       "environmentVariables": {
26         "ASPNETCORE_ENVIRONMENT": "Development"
27       }
28     }
29   }
30 }

以上我们有两个配置项
IIS Express 和WebApiTest

当我们通过按CTRL + F5或只是F5从 Visual Studio 运行项目时。 默认情况下,使用调用配置文件名称"commandName": "IISExpress",。 另外一种情况,如果我们使用.NET Core CLI(dotnet run)运行项目,则使用带有"commandName": "Project",的配置文件 。

我们可以通过单击 Visual Studio 中的下拉列表来更改要使用的配置文件中 .commandName 属性,修改默认设置。

通过 GUI 来设置

使用 GUI 我们可以更改launchSettings.json文件中的设置。

注意,环境变量“ASPNETCORE_ENVIRONMENT”设置的默认设置为“Development”。

还可以添加新的环境变量。这些环境变量在我们的 Asp.Net Core 应用程序中都可用,我们可以包含根据这些环境变量的值有条件地执行的代码。

标签:WebApi,Core,文件,commandName,环境变量,json,Net,NET
来源: https://www.cnblogs.com/orkvfw/p/13915762.html