在.NETwebApi当中有一个配置文件夹LaunchSettings.json;主要用于定义如何启动和调试应用程序。以下是各部分的详细解释:
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,//设置为 false 表示在IIS和IIS Express中不启用Windows身份验证
"anonymousAuthentication": true,//设置为 true 表示在IIS和IIS Express中启用匿名身份验证
"iisExpress": {
"applicationUrl": "http://localhost:17897",//应用程序在IIS Express中运行时使用的URL
"sslPort": 44371
}
},
"profiles": {
"http": {
"commandName": "Project",// 这个配置使用“Project”模式启动,通常指直接通过项目启动
"dotnetRunMessages": true,//设置为 true,在运行时显示构建消息
"launchBrowser": true,//设置为 true,启动时自动打开浏览器
"launchUrl": "weatherforecast",//浏览器启动时打开的网址后缀,这里是 weatherforecast
"applicationUrl": "http://localhost:5173",//应用程序的访问URL
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"//设置环境变量,这里设置 ASPNETCORE_ENVIRONMENT 为 Development,表示开发环境。
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:7077;http://localhost:5173",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",//使用 IISExpress 模式启动,通常指在IIS Express环境中启动
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}