亦庄网站设计,金乡网站建设,国内室内设计网站推荐,珠三角网站建设方式一#xff0c;修改配置文件 appsettings.json
找到文件 appsettings.json#xff0c; 添加如下节点配置#xff0c;在linux环境需要设置0.0.0.0才可以正常代表本机#xff0c;然后被其他机器访问#xff0c;此处设置端口8000#xff0c; Kestrel: {修改配置文件 appsettings.json
找到文件 appsettings.json 添加如下节点配置在linux环境需要设置0.0.0.0才可以正常代表本机然后被其他机器访问此处设置端口8000 Kestrel: {Endpoints: {MyHttpEndpoint: {Url: http://0.0.0.0:8000}}}或者 ,Kestrel: {Endpoints: {MyHttpEndpoint: {//0.0.0.0或* 有效用于linux、windows// Url: http://0.0.0.0:8000 Url: http://*:8000}}}appsettings.json 完整代码参考
{Logging: {LogLevel: {Default: Information,Microsoft.AspNetCore: Warning}},AllowedHosts: *,Kestrel: {Endpoints: {MyHttpEndpoint: {//0.0.0.0或* 有效用于linux、windows// Url: http://0.0.0.0:8000 Url: http://*:8000}}}
}
方式二代码添加端口
var builder WebApplication.CreateBuilder(args);builder.WebHost.ConfigureKestrel((context, serverOptions)
{serverOptions.Listen(IPAddress.Loopback, 5900);serverOptions.Listen(IPAddress.Loopback, 5901, listenOptions {listenOptions.UseHttps(testCert.pfx, testPassword);});
});微软帮助文档 https://learn.microsoft.com/zh-cn/aspnet/core/fundamentals/servers/kestrel/endpoints?viewaspnetcore-9.0#specify-ports-only