'How to add global route prefix in asp.net core 6 [duplicate]

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


Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sergii Zhuravskyi