How to add global route prefix in asp.net core 6

Viewed 2364

Unfortunately, advices for previous versions didn't work How to add global route prefix in asp.net core 3?

app.UsePathBase(new PathString("/api"));

nor this one

public static class MvcOptionsExtensions
{
    public static void UseGeneralRoutePrefix(this MvcOptions opts, IRouteTemplateProvider routeAttribute)
    {
        opts.Conventions.Add(new RoutePrefixConvention(routeAttribute));
    }

    public static void UseGeneralRoutePrefix(this MvcOptions opts, string 
    prefix)
    {
        opts.UseGeneralRoutePrefix(new RouteAttribute(prefix));
    }
}
1 Answers

Sorry silly me, works fine

app.UsePathBase(new PathString("/api/service"));
app.UseRouting();

Just add app.UseRouting();

I don't mind closing the question if you think that it is appropriate.

Related