launchSettings.json
适用于开发环境开发环境和 launchSettings.json。ASPNETCORE_URLS
环境变量。
使用 dotnet
命令和 --urls
参数。
dotnet yourdll.dll --urls http://+:2222
UseUrls
扩展方法。
urls
主机配置键。
如果我们想要设置 Kestrel 端点,请按照以下步骤设置您的项目 appsettings 中的 URL。
Kestrel / EndPoints / Http / Url
{
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://+:2222"
}
}
}
}
launchSettings.json
中的端口值是无关紧要的吗? - variablelaunchSettings.json
适用于开发环境。详见 https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-6.0#development-and-launchsettingsjson - D-Shihhttp://+:2222
中的+
是什么意思? - variable*
和+
并不特殊。任何未被识别为有效IP地址或本地主机的内容都会绑定到所有IPv4和IPv6 IP上。https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-6.0#url-prefixes - D-Shih