.NET Core修改监听端口

时间:2022-11-30 16:53:23

把Program.cs加一行UseUrls代码如下:

using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder; namespace HelloMvc
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseDefaultHostingConfiguration(args)
.UseIIS()
.UseStartup<Startup>()
.UseUrls("http://*:8888")
.Build(); host.Run();
}
}
}