Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.InvalidOperationException: 'A path base can only be configured using IApplicationBuilder.UsePathBase().' [duplicate]

I have an ASP.Net Core 2 Solution running in Docker which is working fine on 1 machine the is running VS 2017 Professional but on another machine running VS 2017 Community I am getting the following error

"System.InvalidOperationException: 'A path base can only be configured using IApplicationBuilder.UsePathBase().'"

when I try and start or debug the solution using docker. If I start the solution with IIS Express it works fine.

There is nothing special about my project:

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();     } } 

I also get this pop up in a new window:

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() 

Everything i've read on this issue don't seem related. Any ideas?

like image 325
Andrew Harris Avatar asked Oct 14 '17 21:10

Andrew Harris


1 Answers

I was setting the relative path within applicationUrl in launchSettings.json which was causing the error:

"applicationUrl": "https://localhost:5001/admin", 

I changed that back to the root URL and instead added a launchUrl with the path which fixed the error and launched the path I wanted on start:

"applicationUrl": "https://localhost:5001", "launchUrl": "admin" 
like image 54
Saeb Amini Avatar answered Sep 22 '22 18:09

Saeb Amini