System.InvalidOperationException:“path基础只能使用IApplicationBuilder.UsePathBase()configuration。

我有一个在Docker中运行的ASP.Net核心2解决scheme,它正在运行VS 1专业版,但在运行VS 2017的另一台机器上工作正常社区我收到以下错误

“System.InvalidOperationException:”path基础只能使用IApplicationBuilder.UsePathBase()configuration。

当我尝试使用docker启动或debugging解决scheme时。 如果我用IIS Express启动解决scheme,它工作正常。

我的项目没有什么特别之处:

public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); // <- Exception happens here } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .CaptureStartupErrors(true) .UseStartup<Startup>() .Build(); } public class Startup { public Startup(IHostingEnvironment env) { } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); } } 

我也会popup一个新窗口:

 crit: Microsoft.AspNetCore.Server.Kestrel[0] Unable to start Kestrel. System.InvalidOperationException: A path base can only be configured using IApplicationBuilder.UsePathBase(). at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAddressAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.<BindAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<StartAsync>d__21`1.MoveNext() 

我在这个问题上读到的一切似乎都没有关系。 有任何想法吗?

尝试在运行时在launchOptions中向applicationUrl添加基本path。

参考: 在这里检查