环境:vs2019,.net core 5.0,CentOS 7
1、先得有一个.net core webapi。注意点:如果没有准备对https进行配置,请不要勾选。如下图
2、修改待发布后的监听端口
- 2.1 找到文件appsettings.json,添加参数,比如"Urls": "http://*:6002;" 结果代码如下:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Urls": "http://*:6002;"
}
- 2.2找到Program.cs,把2.1设置的参数加CreateHostBuilder方法中。结果代码如下:
p