question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to start Kestrel: path base can only be configured using IApplicationBuilder.UsePathBase

See original GitHub issue

From @JDGHHou on September 4, 2018 19:3

My application runs fine in Visual Studio 2017 using the built-in IIS Express. However, when I deploy my code to IIS, suddenly I get the attached error.

I have found a couple of articles saying that I need to set my application URL to “applicationUrl”: “http://localhost/” rather than “applicationUrl”: “http://localhost/{my application name}/”

But when I do that, my application tries to deploy to the webroot, and my application is stored in a folder elsewhere, so that doesn’t work.

In all this, I am so confused as to what Microsoft’s approach is. Why - if IIS Express works great at the press of a button - doesn’t Microsoft just copy that exactly and apply it to IIS? I understand there may be more in-depth configuration a user may need to do, but that should be optional for users who need something more complex. Deploying something in IIS is almost always a complete living nightmare involving a million random undocumented settings. It is needlessly difficult and seems to default to the most random edge-case setup, rather than the most simple.

Anyway… Can someone please tell me how to make my application just deploy to IIS and work the same as it already does on other Microsoft products?

----------THIS IS THE ERROR MESSAGE -------------------- System.InvalidOperationException: ‘A path base can only be configured using IApplicationBuilder.UsePathBase().’

info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] User profile is available. Using ‘C:\Users\JohnDunn\AppData\Local\ASP.NET\DataProtection-Keys’ as key repository and Windows DPAPI to encrypt keys at rest. 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.ParseAddress(String address, Boolean& https) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func2 createBinding) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken)

Copied from original issue: aspnet/KestrelHttpServer#2882

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
JunTaoLuocommented, Sep 4, 2018

@shirhatti Where do we have guidance on IIS deployments? https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.1&tabs=aspnetcore2x?

@JDGHHou This isn’t a Kestrel specific issue but the error is caused by trying to set a path base via the applicationUrl configuration, which is not supported. Instead, you should be using the UsePathBase method as suggested in the error message, for example, keep the applicationUrl set to “http://localhost/” and use the following Configure method

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UsePathBase("{my application name}");
            app.Run(context =>
            {
                return context.Response.WriteAsync("Hello World!");
            });
        }
1reaction
JDGHHoucommented, Sep 10, 2018

I basically just need to take an application that works fine when I launch it in IIS Express and publish it to standalone IIS and have it run the same way. It shouldn’t be difficult. Microsoft has done an excellent job of providing a quick and painless web host in IIS Express, and I don’t understand why the same code doesn’t just work the same way in IIS.

On Mon, Sep 10, 2018, 1:24 PM Eilon Lipton notifications@github.com wrote:

@JDGHHou https://github.com/JDGHHou do you have any additional info on this so that we can investigate?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/Home/issues/3495#issuecomment-420007470, or mute the thread https://github.com/notifications/unsubscribe-auth/AOwWP5X8nyUWLl0SALjGnzF0betTrT3rks5uZqsFgaJpZM4WZrSA .

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.InvalidOperationException: 'A path base can only ...
I was setting the relative path within applicationUrl in launchSettings.json which was causing the error:
Read more >
ASP.NET Core App fails to start with error: 'A path base can ...
The error message was like below: System.InvalidOperationException: A path base can only be configured using IApplicationBuilder.UsePathBase().
Read more >
Using PathBase with .NET 6's WebApplicationBuilder
In this post I describe the difficulties of adding calls to UsePathBase with .NET 6 WebApplication programs, and describe two approaches to ...
Read more >
'A path base can only be configured using ...
Server.Kestrel[0] Unable to start Kestrel. System.InvalidOperationException: A path base can only be configured using IApplicationBuilder.UsePathBase(). at ...
Read more >
UsePathBaseExtensions.UsePathBase(IApplicationBuilder ...
Adds a middleware that extracts the specified path base from request path and postpend it to the request path base.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found