Skip to content

UsePathBase does not work as expected in .NET 6 #45076

@abrasat

Description

@abrasat

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The application calls app.UsePathBase() before app.UseRouting(), as recommended workaround described here . The controller method is reachable over both /xxx and /MyBasePath/xxx URLs. Swagger displays /xxx as method url.

...
app.UsePathBase("/MyBasePath");

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
  app.UseSwagger();
  app.UseSwaggerUI();
}
app.UseRouting();
...

Expected Behavior

The controller method should be reachable only over /MyBasePath/xxx URL.
Swagger should display /MyBasePath/xxx

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

7.0.100

Anything else?

The ASP.NET Core application targets NET 6,.
VS 2022 is used as IDE

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions