Open Closed

I have issue when I try to Publish On IIS #10431


User avatar
0
ttrahmo created

Dear Team,

I am Published the site in the HRBack it is working fine, but after I create Application and the site call "DataSharing" in IIS give me error as attached file he can't load API swagger. Please I need from your side to check what i miss from the configuration to allow the swagger working under the Site name "DataSharing" and Application.

Thanks


41 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • In ABP (v9), when you host the HttpApi.Host under an IIS Application / virtual directory (e.g. https://eform/HRBack), Swagger UI must request the swagger json with the same PathBase. If Swagger UI is configured with an absolute path like /swagger/v1/swagger.json, it will try to load it from the web site root, not from /HRBack, and you’ll see “Failed to load API definition”.

    Fix (recommended)

    1. Keep your App:PathBase as you already have:
    "App": {
      "PathBase": "/HRBack",
      "SelfUrl": "https://eform/HRBack"
    }
    
    1. Update your Swagger UI configuration to use abp.appPath (PathBase-aware) when setting the endpoint.

    In your *.HttpApi.Host module (typically OnApplicationInitialization), ensure it’s like this:

    app.UseSwagger();
    
    app.UseAbpSwaggerUI(options =>
    {
        options.SwaggerEndpoint($"{app.ApplicationServices.GetRequiredService<IConfiguration>()["App:PathBase"]}/swagger/v1/swagger.json", "API");
    });
    

    Better / cleaner (doesn’t rely on config string concatenation) is to use ABP’s abp.appPath on the UI side, but in Swashbuckle options you typically hardcode. The key point is: the endpoint must start with /HRBack (your PathBase), not /swagger/....

    So for your case it must be:

    /HRBack/swagger/v1/swagger.json
    
    1. Make sure your IIS application is configured as an Application (not just a folder) and uses the correct app pool (.NET CLR “No Managed Code” for ASP.NET Core hosting model).

    Why your log looks “OK but UI fails”

    Your server log shows GET https://eform/HRBack/swagger/v1/swagger.json returns 200. Swagger UI’s error often appears when the UI is actually trying a different URL (commonly /swagger/v1/swagger.json without /HRBack) or when the browser blocks it due to mixed origin / redirect. Ensuring the SwaggerEndpoint includes the PathBase resolves the common IIS-virtual-directory case.


    • https://abp.io/docs/latest/framework/api-development/swagger
    • https://abp.io/community/articles/mb2w01fe

    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
    ttrahmo created

    Dear Team,

    I did all the same but still not solve and show the same error.

    Thanks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    What are http response of https://eform/HRBack/swagger/v1/swagger.json?

    Thanks.

  • User Avatar
    0
    ttrahmo created

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi

    What are error messages in browser console?

    Can you share a online url to check it?

    liming.ma@volosoft.com Thanks

  • User Avatar
    0
    ttrahmo created

    Dear Team,

    I can't share the link the server Internal Only.

  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • Your Swagger JSON is reachable (you can open https://eform/HRBack/swagger/v1/swagger.json in the browser), so the problem is not Swagger generation.
    • The browser console error in your screenshot is the key:

    GET https://eform/api/abp/application-configuration 404 (Not Found) (from abp.swagger.js)

    That means Swagger UI is trying to call ABP’s application-configuration endpoint from the site root (/api/...) instead of from your virtual directory (/HRBack/api/...). So ABP’s swagger helper script doesn’t know your PathBase, and Swagger UI fails even though the swagger.json itself is OK.

    Solution

    1) Ensure your PathBase is applied BEFORE ABP middleware

    In your *.HttpApi.Host OnApplicationInitialization, make sure UsePathBase("/HRBack") (or ABP’s equivalent configuration) is executed early (before UseStaticFiles, UseSwaggerUI, etc.).

    Example:

    public override void OnApplicationInitialization(ApplicationInitializationContext context)
    {
        var app = context.GetApplicationBuilder();
        var env = context.GetEnvironment();
        var configuration = context.GetConfiguration();
    
        var pathBase = configuration["App:PathBase"];
        if (!pathBase.IsNullOrWhiteSpace())
        {
            app.UsePathBase(pathBase);
        }
    
        app.UseCorrelationId();
        app.UseStaticFiles();
        app.UseRouting();
    
        app.UseSwagger();
        app.UseAbpSwaggerUI(options =>
        {
            options.SwaggerEndpoint($"{pathBase}/swagger/v1/swagger.json", "API");
        });
    
        app.UseConfiguredEndpoints();
    }
    

    2) Fix the swagger UI “ABP script” base path (most important)

    ABP injects /swagger/ui/abp.swagger.js and that script calls abp/appPath-dependent endpoints like api/abp/application-configuration. If abp.appPath is not set correctly, it defaults to / and you get exactly your 404.

    To force the correct base path for swagger UI under /HRBack, add this right before UseAbpSwaggerUI:

    app.Use((ctx, next) =>
    {
        // Force ABP appPath for swagger UI under a virtual directory
        if (ctx.Request.Path.StartsWithSegments("/swagger"))
        {
            ctx.Items["__abp_app_path"] = configuration["App:PathBase"]?.EnsureEndsWith('/');
        }
        return next();
    });
    

    If you don’t want middleware tricks, the practical workaround is:

    • Disable ABP’s swagger UI injected script and use plain UseSwaggerUI(...) without ABP additions, OR
    • Serve swagger at root instead of under an IIS Application.

    (Your specific symptom is produced by ABP’s injected script calling /api/abp/application-configuration.)

    3) Quick verification (what should happen after fix)

    Open browser devtools Network tab and refresh /HRBack/swagger/index.html:

    • GET https://eform/HRBack/api/abp/application-configuration should return 200
    • No request should go to https://eform/api/abp/application-configuration

    If you still see calls going to /api/... (without /HRBack), the PathBase is not being applied to swagger UI runtime variables.


    • https://abp.io/docs/latest/framework/api-development/swagger

    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
    maliming created
    Support Team Fullstack Developer

    hi

    Can you check your api website?

    This endpoint is 404 now.

    https://eform/api/abp/application-configuration 404 (Not Found)

    Thanks.

  • User Avatar
    0
    ttrahmo created

    Dears,

    I using this Link https://eform/HRBack/api/abp/application-configuration

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can try the code below(replace myscript tag with script):

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

    Thanks.

  • User Avatar
    0
    ttrahmo created

    Dear Team,

    I Got error after I re build and upload to the server.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please share the html source code of your current swagger Index.html

    liming.ma@volosoft.com

    Thanks.

  • User Avatar
    0
    ttrahmo created

    Dear Team,

    I already send the request from eMail Comdot2100@hotmail.com

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Thanks. Can you share the html source code of swagger website?

    Chrome ->

  • User Avatar
    0
    ttrahmo created

    Dear Team, I already send the request from eMail Comdot2100@hotmail.com

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The index.html code is not from Swagger, can you check and share again?

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    And update code like below:

  • User Avatar
    0
    ttrahmo created

    Dear Team,

    I open the front angular , but when I try to save data give me error.

    Thanks

  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • Your Swagger issue and your new Angular “save” issue have the same root cause: the app is hosted under /HRBack but some requests are still going to the site root (missing /HRBack), so IIS returns 404/400 and ABP shows “Error detail not sent by the server.”

    From your screenshot, the browser is calling an error page under:

    /HRBack/Error?httpStatusCode=400

    That typically happens when the API call URL is wrong (PathBase missing) or the server rejects the request and ABP redirects to the Error page in production.

    Solution

    1) Fix Angular environment to include the PathBase for API + OAuth issuer

    In your Angular environment.prod.ts (or the environment you deploy), ensure all URLs include /HRBack where appropriate:

    export const environment = {
      production: true,
      application: {
        baseUrl: 'https://eform/HR/',           // Angular site base
        // If Angular itself is under /HR, keep it. Otherwise adjust.
      },
      oAuthConfig: {
        issuer: 'https://eform/HRBack',         // AuthServer/Authority (MUST match exactly)
        clientId: 'TNAPLanner_App',             // your angular client id
        scope: 'offline_access ...',            // keep your existing scopes
      },
      apis: {
        default: {
          url: 'https://eform/HRBack',          // IMPORTANT: API root including /HRBack
          rootNamespace: '...',                // keep existing
        },
      },
    };
    

    After deploying, open DevTools → Network and verify that save (POST/PUT) requests go to:

    • https://eform/HRBack/api/... and not:
    • https://eform/api/...

    2) Ensure backend knows it is running under /HRBack

    On HttpApi.Host side you already have it, but verify production config is deployed:

    "App": {
      "SelfUrl": "https://eform/HRBack",
      "PathBase": "/HRBack"
    },
    "AuthServer": {
      "Authority": "https://eform/HRBack",
      "RequireHttpsMetadata": true
    }
    

    3) If only POST/PUT fail on IIS: disable WebDAV module (classic IIS issue)

    If GET works but POST/PUT/DELETE fail or return 400 under IIS, remove/disable WebDAV for that site (or server) because it can block verbs.

    This is a common IIS deployment step and ABP’s IIS deployment doc covers IIS-side requirements.

    What you should see after the fix

    • Angular “save” requests return 200/204 (or validation errors with JSON), not .../Error?httpStatusCode=400
    • Swagger UI no longer requests /api/abp/application-configuration from the root

    https://abp.io/docs/latest/solution-templates/layered-web-application/deployment/deployment-iis
    https://abp.io/docs/latest/framework/api-development/swagger


    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
    maliming created
    Support Team Fullstack Developer

    Hi

    Can you check and share api website logs?

    You can share the logs.txt file to liming.ma@volosoft.com

    Thanks.

  • User Avatar
    0
    ttrahmo created

    Dear Team,

    I sent eMail to you. okool_tarek.rahmo@rta.ae

    Thanks

  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • Since https://eform/HRBack/api/abp/application-configuration returns 200, but your browser console still shows requests going to /api/abp/application-configuration (without /HRBack), the only remaining fix is to force abp.appPath for Swagger UI (and ensure the Swagger endpoint also includes /HRBack). Otherwise abp.swagger.js will keep calling the root.

    Use this exact configuration in *.HttpApi.Host OnApplicationInitialization (note the real <script> tag and the /HRBack/ trailing slash):

    app.UseSwagger();
    
    app.UseAbpSwaggerUI(options =>
    {
        // Important: Use the correct Swagger JSON URL under the virtual directory
        options.SwaggerEndpoint("/HRBack/swagger/v1/swagger.json", "My API");
    
        // Important: Force ABP base path for swagger UI script (abp.swagger.js)
        var builder = new StringBuilder(options.HeadContent);
        builder.AppendLine("<script>abp.appPath = '/HRBack/';</script>");
        options.HeadContent = builder.ToString();
    
        var configuration = context.GetConfiguration();
        options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
    });
    

    After republish, hard refresh the swagger page (Ctrl+F5) and confirm in DevTools → Network:

    • GET https://eform/HRBack/api/abp/application-configuration is 200
    • There is no request to https://eform/api/abp/application-configuration

    This is the same root cause you saw earlier: Swagger UI works, swagger.json is OK, but abp.swagger.js uses abp.appPath and defaults to / unless you force it under an IIS virtual directory.


    • https://abp.io/docs/latest/framework/api-development/swagger

    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
    ttrahmo created

    Dear Team,

    After I re build the back, I try again the back working fine but when i go to front I got this error

    Thanks

  • User Avatar
    0
    ttrahmo created

    Dear Team,

    The site open , but when I try to update user just press save only give me this error

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The logs don't show any errors.

    Could you enable debug logging, reproduce the issue, and share the logs again (including the HAR files for the Angular and MVC apps)?

    var loggerConfiguration = new LoggerConfiguration()
        .MinimumLevel.Debug()
        .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
        .Enrich.FromLogContext()
        .WriteTo.Async(c => c.File("Logs/logs.txt"))
    

    https://abp.io/support/questions/8622/

    https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems#answer-3a1a1c4b-691e-3403-98b9-5f23fa024759

    You can delete the logs.txt and let the app recreate it.

    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 17, 2026, 09:10
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.