发布应用后,我无法启动dotnet core应用。 dotnet run
在开发环境中启动应用程序时,尝试在发布后启动应用程序只会引发此错误。
crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.FormatException: Invalid URL: 'http:////*:80'.
at Microsoft.AspNetCore.Server.Kestrel.Core.ServerAddress.FromUrl(String url)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.ParseAddress(String address, Boolean& https)
at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.ValidateOptions()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
Unhandled Exception: System.FormatException: Invalid URL: 'http:////*:80'.
at Microsoft.AspNetCore.Server.Kestrel.Core.ServerAddress.FromUrl(String url)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.ParseAddress(String address, Boolean& https)
at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.ValidateOptions()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at NiqVive.Api.Program.Main(String[] args) in /home/sav/github/nForTics/NiqVive/NiqVive.Api/Program.cs:line 12
[1] 29044 abort (core dumped) dotnet NiqVive.Api.dll
这是我的Program.cs
namespace NiqVive.Api
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Listen(IPAddress.Any, 5007);
options.Limits.MaxRequestBodySize = null;
})
.UseDefaultServiceProvider(options => {
options.ValidateScopes = false;
});
}
}
-硬件 版本:2.1.401
运行时环境: 操作系统名称:ubuntu 作业系统版本:18.04 RID:ubuntu.18.04-x64 基本路径:/usr/share/dotnet/sdk/2.1.401 /
如果我发布该应用程序,则不会开始。
答案 0 :(得分:1)
转到“ Properties”文件夹并打开launchSetting.json文件,以其他方式更改端口号 在“ applicationUrl”:“ http://localhost:5001;http://localhost:4000”中,这里我们有http://localhost:5000将其更改为另一个端口