Open Closed

We need a meeting to take sample abp mvc layered project using pathbased routing #10387


User avatar
0
sghorakavi@cpat.com created
  • goal is Auth goes to https://localhost:44318/auth Host API server goes to https://localhost:44392/portal/api Web server goes to https://localhost:44374/portal

7 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • What you want is PathBase / virtual directory hosting for each app in a tiered MVC solution:

      • AuthServer: https://localhost:44318/auth
      • HttpApi.Host: https://localhost:44392/portal/api
      • Web (MVC UI): https://localhost:44374/portal
    • In ABP (including v9.3.6), the reliable way to do this is:

      1. Set PathBase (ASP.NET Core UsePathBase) for each application.
      2. Ensure ABP-generated URLs are correct by setting SelfUrl (and the relevant remote service base URLs) to include the same base path.
      3. Update OpenIddict client redirect/logout URLs (seed data / DbMigrator / appsettings) to include /portal/... and /auth/....
      4. Make sure cookies work with these base paths (cookie path considerations).

    1) AuthServer at /auth

    In AuthServer (YourProject.AuthServer) add PathBase early in the pipeline:

    // in OnApplicationInitialization / Program.cs pipeline
    app.UsePathBase("/auth");
    

    Then set AuthServer self URL accordingly in appsettings.json:

    "App": {
      "SelfUrl": "https://localhost:44318/auth"
    }
    

    Also ensure the OIDC issuer/authority used by clients points to:

    • https://localhost:44318/auth

    2) HttpApi.Host at /portal/api

    In HttpApi.Host add:

    app.UsePathBase("/portal/api");
    

    Set:

    "App": {
      "SelfUrl": "https://localhost:44392/portal/api"
    }
    

    If your MVC UI calls this API via remote services, set the remote service base URL (commonly in Web project) to include /portal/api.

    3) MVC Web at /portal

    In Web (MVC UI) add:

    app.UsePathBase("/portal");
    

    Set:

    "App": {
      "SelfUrl": "https://localhost:44374/portal"
    }
    

    And update the AuthServer authority used by Web:

    "AuthServer": {
      "Authority": "https://localhost:44318/auth",
      "RequireHttpsMetadata": "false"
    }
    

    4) Update OpenIddict client redirect URIs (critical)

    Because you changed the base paths, the redirect endpoints change too:

    • Web redirect URI becomes:
      • https://localhost:44374/portal/signin-oidc
    • Web post logout redirect becomes:
      • https://localhost:44374/portal/signout-callback-oidc
    • Swagger redirect (if used on API) becomes:
      • https://localhost:44392/portal/api/swagger/oauth2-redirect.html

    So you must update your OpenIddict application/client configuration in the database (or via ABP data seeding / DbMigrator configuration) to use the new URLs.

    5) Notes about “meeting”

    For non-technical requests like arranging a meeting, please contact us at:

    • https://abp.io/contact

    (sources)

    • https://abp.io/docs/latest/solution-templates/layered-web-application/solution-structure
    • https://abp.io/support/questions/1048
    • https://abp.io/contact

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    sghorakavi@cpat.com created

    the swagger.json file path is incorrect from https://localhost:44392/portal/api => opens https://localhost:44392/swagger/v1/swagger.json

    swagger.json and application-configuration are not using the correct paths, they should be prefixed with /portal/api/

    <br>

  • User Avatar
    1
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try to set the abp.appPath?

    Please relace myscript with script

    app.UseAbpSwaggerUI(options =>
    {
        options.SwaggerEndpoint("/mytest/swagger/v1/swagger.json", "Test MyProjectName API");
    
        var builder = new StringBuilder(options.HeadContent);
        builder.AppendLine($"<myscript>abp.appPath = '/mytest/';</myscript>");
        options.HeadContent = builder.ToString();
    
    });
    

    Thanks.

  • User Avatar
    0
    sghorakavi@cpat.com created

    [maliming] said: hi

    Can you try to set the abp.appPath?

    Please relace myscript with script

    app.UseAbpSwaggerUI(options => 
    { 
        options.SwaggerEndpoint("/mytest/swagger/v1/swagger.json", "Test MyProjectName API"); 
     
        var builder = new StringBuilder(options.HeadContent); 
        builder.AppendLine($"<myscript>abp.appPath = '/mytest/';</myscript>"); 
        options.HeadContent = builder.ToString(); 
     
    }); 
    

    Thanks.

    Thank you, Can you pls send me sample script ?

    Here is our code now

    app.UseSwagger();
     app.UseAbpSwaggerUI(options =>
     {
         options.SwaggerEndpoint("/swagger/v1/swagger.json", "Approach API");
    
         var configuration = context.GetConfiguration();
         options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
     });
    

    We use app.UsePathBase("/portal/api"); in the program.cs

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can try code below:

    app.UseSwagger();
    app.UseAbpSwaggerUI(options =>
    {
        options.SwaggerEndpoint("/portal/api/swagger/v1/swagger.json", "Approach API");
        
        var builder = new StringBuilder(options.HeadContent); 
        builder.AppendLine($"<myscript>abp.appPath = '/portal/api/';</myscript>"); 
        options.HeadContent = builder.ToString(); 
        
        var configuration = context.GetConfiguration();
        options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
    });
    

    Thanks.

  • User Avatar
    0
    sghorakavi@cpat.com created

    [maliming] said: hi

    You can try code below:

    app.UseSwagger(); 
    app.UseAbpSwaggerUI(options => 
    { 
        options.SwaggerEndpoint("/portal/api/swagger/v1/swagger.json", "Approach API"); 
         
        var builder = new StringBuilder(options.HeadContent);  
        builder.AppendLine($"<myscript>abp.appPath = '/portal/api/';</myscript>");  
        options.HeadContent = builder.ToString();  
         
        var configuration = context.GetConfiguration(); 
        options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); 
    }); 
    

    Thanks.

    Testing with `app.UseAbpSwaggerUI(options => { options.SwaggerEndpoint("portal/api/swagger/v1/swagger.json", "Approach API");

    var builder = new StringBuilder(options.HeadContent);
    builder.AppendLine($"<myscript>abp.appPath = '/portal/api/';</myscript>");
    options.HeadContent = builder.ToString();
    
    options.OAuthClientId("Approach_Swagger");
    options.OAuthScopes("openid", "profile", "email", "roles", "Approach");
    options.OAuth2RedirectUrl("https://localhost:44392/portal/api/swagger/oauth2-redirect.html");
    

    });` will send you update soon

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please replace myscript with script

    Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.2.0-preview. Updated on February 05, 2026, 13:24
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.