And*_*ris 6 c# docker asp.net-core-2.0
我有一个在Docker中运行的ASP.Net Core 2解决方案,它在运行VS 2017 Professional的一台机器上运行正常,但是在运行VS 2017 Community的另一台机器上却出现以下错误
“ System.InvalidOperationException:'只能使用IApplicationBuilder.UsePathBase()配置路径库。
当我尝试使用docker启动或调试解决方案时。如果我使用IIS Express启动解决方案,则效果很好。
我的项目没有什么特别的:
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();
}
}
Run Code Online (Sandbox Code Playgroud)
我也在新窗口中弹出此窗口:
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()
Run Code Online (Sandbox Code Playgroud)
我在这个问题上阅读的所有内容似乎都不相关。有任何想法吗?
Sae*_*ini 37
我设置中的相对路径applicationUrl中launchSettings.json这是导致错误:
"applicationUrl": "https://localhost:5001/admin",
Run Code Online (Sandbox Code Playgroud)
我把它改回根 URL,而是添加了一个launchUrl修复错误的路径,并在开始时启动了我想要的路径:
"applicationUrl": "https://localhost:5001",
"launchUrl": "admin"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6773 次 |
| 最近记录: |