我有一个在Docker中运行的ASP.Net核心2解决方案,它在1台机器上运行良好,运行的是VS 2017专业人员,但在另一台运行VS 2017社区的机器上运行,我得到以下错误
"System.InvalidOperationException:‘只能使用IApplicationBuilder.UsePathBase()配置路径库’。“
当我尝试使用docker启动或调试解决方案时。如果我用IIS启动解决方案,它可以正常工作。
我的项目没有什么特别之处:
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();
}
}
我还在一个新窗口里弹出了这个:
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()
我在这个问题上读到的所有东西似乎都与此无关。有什么想法吗?
发布于 2020-06-16 06:56:48
我在applicationUrl
中设置了launchSettings.json
中的相对路径,这导致了错误:
"applicationUrl": "https://localhost:5001/admin",
我将其更改为根URL,并添加了一个launchUrl
,其中包含了修复错误的路径,并在开始时启动了我想要的路径:
"applicationUrl": "https://localhost:5001",
"launchUrl": "admin"
https://stackoverflow.com/questions/46749411
复制相似问题