C# 如何在端口5003上运行asp.net核心api?
我需要在端口5003上运行我的asp.net核心api,如何做到这一点?(端口5000已被另一个asp.het核心api使用) 我面临::未处理的异常:System.IO.IOException:无法绑定到地址:地址已在使用中 下面是我的launchSettings.jsonC# 如何在端口5003上运行asp.net核心api?,c#,C#,我需要在端口5003上运行我的asp.net核心api,如何做到这一点?(端口5000已被另一个asp.het核心api使用) 我面临::未处理的异常:System.IO.IOException:无法绑定到地址:地址已在使用中 下面是我的launchSettings.json { "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpre
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5003",
"sslPort": 5002
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"myapp": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5003;https://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
还有我的startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
ILoggerFactory loggerFactory)
{
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseHsts();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}");
});
设置为
publicstaticvoidmain(字符串[]args)
{
CreateWebHostBuilder(args.Build().Run();
}
公共静态IWebHostBuilder CreateWebHostBuilder(字符串[]args)=>
WebHost.CreateDefaultBuilder(args)
.UseStartup()
.useURL(“http://*:5003”);
所有URL似乎都已经有了端口5003。问题是什么?我面临:未处理的异常:System.IO.IOException:绑定到地址失败:地址已在使用端口5000。5003怎么样?看起来它一直在使用端口5000顺便说一句,我正在使用centOS 7把它放在哪里?@Donald在你的程序中。csit现在正在运行,但我仍然无法访问它?503-服务不可用
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://*:5003");