ASP.NET Core 2.0系列学习笔记-应用程序修改默认端口支持外网IP访问

ASP.NET Core 2.0 MVC默认端口是:http://localhost:5000/,不支持外网ip访问,此处提供两种修改方式:

方式一:代码指定修改;

public static IWebHost BuildWebHost(string[] args) =>
       WebHost.CreateDefaultBuilder(args)
           .UseUrls("http://*:5000") //如果不配置下面这条信息,会导致无法直接访问
           .UseStartup<Startup>()
           .Build();

如果端口号要修改其他,对应的写上要修改的端口号即可。

方式二:修改配置,选择当前项目=>属性=>调试:应用URL输入要指定的端口号;


保存,生成项目(编译)即可。

猜你喜欢

转载自blog.csdn.net/chaitsimplelove/article/details/79415477