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.
41 Answer(s)
-
0
- 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)
- Keep your
App:PathBaseas you already have:
"App": { "PathBase": "/HRBack", "SelfUrl": "https://eform/HRBack" }- Update your Swagger UI configuration to use
abp.appPath(PathBase-aware) when setting the endpoint.
In your
*.HttpApi.Hostmodule (typicallyOnApplicationInitialization), 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.appPathon 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- 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.jsonreturns 200. Swagger UI’s error often appears when the UI is actually trying a different URL (commonly/swagger/v1/swagger.jsonwithout/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.
- In ABP (v9), when you host the HttpApi.Host under an IIS Application / virtual directory (e.g.
-
0
Dear Team,
I did all the same but still not solve and show the same error.
Thanks
-
0
hi
What are http response of
https://eform/HRBack/swagger/v1/swagger.json?Thanks.
-
0
-
0
Hi
What are error messages in browser console?
Can you share a online url to check it?
liming.ma@volosoft.com Thanks
-
0
-
0
- Your Swagger JSON is reachable (you can open
https://eform/HRBack/swagger/v1/swagger.jsonin 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)(fromabp.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.HostOnApplicationInitialization, make sureUsePathBase("/HRBack")(or ABP’s equivalent configuration) is executed early (beforeUseStaticFiles,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.jsand that script callsabp/appPath-dependent endpoints likeapi/abp/application-configuration. Ifabp.appPathis 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 beforeUseAbpSwaggerUI: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-configurationshould 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.
- Your Swagger JSON is reachable (you can open
-
0
hi
Can you check your api website?
This endpoint is 404 now.
https://eform/api/abp/application-configuration 404 (Not Found)Thanks.
-
0
-
0
hi
You can try the code below(replace
myscripttag withscript):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.
-
0
-
0
hi
Please share the html source code of your current swagger
Index.htmlliming.ma@volosoft.com
Thanks.
-
0
Dear Team,
I already send the request from eMail Comdot2100@hotmail.com
-
0
-
0
Dear Team, I already send the request from eMail Comdot2100@hotmail.com
-
0
-
0
-
0
-
0
- Your Swagger issue and your new Angular “save” issue have the same root cause: the app is hosted under
/HRBackbut 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=400That 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/HRBackwhere 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
/HRBackOn
HttpApi.Hostside 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-configurationfrom 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.
- Your Swagger issue and your new Angular “save” issue have the same root cause: the app is hosted under
-
0
Hi
Can you check and share api website logs?
You can share the logs.txt file to liming.ma@volosoft.com
Thanks.
-
0
Dear Team,
I sent eMail to you. okool_tarek.rahmo@rta.ae
Thanks
-
0
- Since
https://eform/HRBack/api/abp/application-configurationreturns 200, but your browser console still shows requests going to/api/abp/application-configuration(without/HRBack), the only remaining fix is to forceabp.appPathfor Swagger UI (and ensure the Swagger endpoint also includes/HRBack). Otherwiseabp.swagger.jswill keep calling the root.
Use this exact configuration in
*.HttpApi.HostOnApplicationInitialization(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-configurationis 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.jsusesabp.appPathand 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.
- Since
-
0
-
0
-
0
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














