-
Notifications
You must be signed in to change notification settings - Fork 199
UsePathBase does not disable root path #893
Comments
It doesn't feel right, but it looks like it probably is to me. For every request there's two paths, the Both the So imagine you have a request for
That's the behaviour you expect I believe. So now lets look at a request for
I believe, what you really want is to have the first scenario only, and for the second scenario to return a 404. In which case, you probably want something closer to this, with a nested public void Configure(IApplicationBuilder app)
{
app.Map("/basepath", mainapp =>
{
mainapp.Map("/ping", map => map.Run(async
ctx => await ctx.Response.WriteAsync("pong")));
mainapp.UseMvc();
});
} This ensures that if the initial |
I understand the expectation, but it is working as intended. UsePathBase is primarily about getting those segments out of your way because they're a deployment detail, and if they stayed it would mess up your routing. Consider the alternative. If it were to disable the root path, how would it do so? A 404 isn't really appropriate, presumably that path is available on a separate instance of your site hosting the root. You could use Map as shown above if you really wanted the 404. IIS/Http.Sys uses a 503 for this scenario, which we could do, but you wouldn't have an opportunity to provide content that fit the theme of your site. The IIS/Http.Sys 503 page is pretty stark. If you wanted a 503 you could use Map and then put a proper error page on the other branch. |
This issue was moved to dotnet/aspnetcore#2698 |
When configuring the base path of the application, the root path continues to work, for example:
With this configuration both
/basepath/ping
and/ping
work. I would expect/ping
to return a 404.This is the same behavior demonstrated by setting ASPNETCORE_URLS to
http://+:5000/basepath
though I believe setting the base path this way has been depreciated.The text was updated successfully, but these errors were encountered: