A) Confirm tenant resolution and middleware order
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseMultiTenancy();
app.UseAuthorization();
app.Use(async (ctx, next) =>
{
var currentTenant = ctx.RequestServices.GetRequiredService<ICurrentTenant>();
var logger = ctx.RequestServices.GetRequiredService<ILogger<YourModule>>();
logger.LogInformation("CurrentTenant: Id={Id}, Name={Name}", currentTenant.Id, currentTenant.Name);
await next();
});
If you consistently see Id = null for authenticated tenant requests, tenant resolution is failing.
B) Validate tenant resolvers (domain/header/claim)
C) Prove the connection string resolver actually returns the tenant DB
public class ConnDebugAppService : ApplicationService
{
private readonly IConnectionStringResolver _resolver;
public ConnDebugAppService(IConnectionStringResolver resolver) => _resolver = resolver;
public async Task<string> GetDefaultConnAsync()
{
return await _resolver.ResolveAsync(ConnectionStrings.DefaultConnectionStringName);
}
}
D) Ensure DbContexts are not pinning the Host connection
Configure<AbpDbContextOptions>(options =>
{
options.Configure<MyMainDbContext>(opt => opt.UseSqlServer());
options.Configure<MyTenantDbContext>(opt => opt.UseSqlServer());
// or UseMySQL/UseNpgsql per context if you have multiple DBMS
});
E) Entities, repositories, and background processes
using (CurrentTenant.Change(tenantId))
{
// repositories/services here
}
F) SaaS connection strings and ABP 9+/10+ validation
[Dependency(ReplaceServices = true)]
public class EncryptedConnectionStringChecker
: SqlServerConnectionStringChecker, IConnectionStringChecker, ITransientDependency
{
private readonly IStringEncryptionService _enc;
public EncryptedConnectionStringChecker(IStringEncryptionService enc) => _enc = enc;
public override async Task<AbpConnectionStringCheckResult> CheckAsync(string connectionString)
{
var plain = _enc.Decrypt(connectionString);
return await base.CheckAsync(plain);
}
}
If the framework thinks the string is invalid, it can silently fall back to Host DB behavior afterward.
G) Turn on DB/EF logging to see which connection is used
Configure<AbpEfCoreOptions>(options =>
{
options.Configure(ctx =>
{
ctx.DbContextOptions
.EnableDetailedErrors()
.EnableSensitiveDataLogging();
});
});
H) Cross-cutting checks that commonly cause “always Host DB”
I) Quick “prove it” steps
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.
A. Verify tenant resolution happens before EF Core runs
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseMultiTenancy();
app.UseAuthorization();
app.Use(async (ctx, next) =>
{
var currentTenant = ctx.RequestServices.GetRequiredService<ICurrentTenant>();
var logger = ctx.RequestServices.GetRequiredService<ILogger<YourModule>>();
logger.LogInformation("TenantId={TenantId}, Name={TenantName}", currentTenant.Id, currentTenant.Name);
await next();
});
B. Confirm entity and repository are multi-tenant aware
public class Product : AggregateRoot<Guid>, IMultiTenant
{
public Guid? TenantId { get; set; }
public string Name { get; set; }
}
using (CurrentTenant.Change(tenantId))
{
// Use repositories/services here so they connect to the tenant DB
}
C. Validate the connection string switching mechanism
[Dependency(ReplaceServices = true)]
public class EncryptedConnectionStringChecker
: SqlServerConnectionStringChecker, IConnectionStringChecker, ITransientDependency
{
private readonly IStringEncryptionService _enc;
public EncryptedConnectionStringChecker(IStringEncryptionService enc) { _enc = enc; }
public override async Task<AbpConnectionStringCheckResult> CheckAsync(string connectionString)
{
var plain = _enc.Decrypt(connectionString);
return await base.CheckAsync(plain);
}
}
D. Ensure DbContext is not statically bound to Host connection
E. Unit of Work and scope boundaries
F. Produce diagnostic logs to pinpoint the problem
Configure<AbpEfCoreOptions>(options =>
{
options.Configure(context =>
{
context.DbContextOptions.UseLoggerFactory(MyLoggerFactory) // with Microsoft.Extensions.Logging console/debug provider
.EnableSensitiveDataLogging();
});
});
public class DebugService : ApplicationService
{
private readonly IConnectionStringResolver _resolver;
public DebugService(IConnectionStringResolver resolver) { _resolver = resolver; }
public async Task<string> GetConnAsync()
{
return await _resolver.ResolveAsync(ConnectionStrings.DefaultConnectionStringName);
}
}
Call it as tenant; it must return the tenant DB connection string.
G. Common misconfigurations that cause “always Host DB”
H. If you use “Separate Tenant Schema” template
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.
What to do
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IConnectionStringChecker))]
public class EncryptedConnectionStringChecker
: SqlServerConnectionStringChecker, IConnectionStringChecker, ITransientDependency
{
private readonly IStringEncryptionService _encryption;
public EncryptedConnectionStringChecker(IStringEncryptionService encryption)
{
_encryption = encryption;
}
public override async Task<AbpConnectionStringCheckResult> CheckAsync(string connectionString)
{
var decrypted = _encryption.Decrypt(connectionString);
return await base.CheckAsync(decrypted);
}
}
Key points
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.
Why the PUT may be skipped
Definitive checks and fixes
Server-side note for encrypted scenarios (ABP ≥ 7.0 validates connection strings):
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IConnectionStringChecker))]
public class EncryptedConnectionStringChecker
: SqlServerConnectionStringChecker, IConnectionStringChecker, ITransientDependency
{
private readonly IStringEncryptionService _encryption;
public EncryptedConnectionStringChecker(IStringEncryptionService encryption)
{
_encryption = encryption;
}
public override async Task<AbpConnectionStringCheckResult> CheckAsync(string connectionString)
{
var decrypted = _encryption.Decrypt(connectionString);
return await base.CheckAsync(decrypted);
}
}
Part 2 — SQL Server remote/named instance support and formats
What ABP supports
Recommended connection string formats
Behavior expectations
Actionable guidance for your case
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.
Code example:
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Volo.Abp.Auditing;
public class SelectiveGetAuditingMatcher : IAuditingMiddlewareMatcherContributor
{
public void Contribute(AuditingMiddlewareMatchingContext context)
{
var httpContext = context.HttpContext;
// Skip non-HTTP GET requests
if (!HttpMethods.IsGet(httpContext.Request.Method))
{
return;
}
// If endpoint metadata contains [DisableAuditing], skip.
var endpoint = httpContext.GetEndpoint();
if (endpoint?.Metadata?.GetMetadata<DisableAuditingAttribute>() != null)
{
return;
}
// Example 1: match by route template (controller/action)
var routeData = httpContext.GetRouteData();
var controller = routeData?.Values["controller"]?.ToString();
var action = routeData?.Values["action"]?.ToString();
// Only audit specific GET actions:
if ((controller, action) is ("Orders", "GetDetails") or ("Reports", "GetMonthly"))
{
context.Matches = true; // audit this request
return;
}
// Example 2 (optional): match by path prefix
// if (httpContext.Request.Path.StartsWithSegments("/api/my-important-read"))
// {
// context.Matches = true;
// }
}
}
Register the contributor and keep IsEnabledForGetRequests = false:
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpAuditingOptions>(options =>
{
options.IsEnabledForGetRequests = false; // keep default
options.AlwaysLogOnException = true; // still log failures
// Add our selective matcher contributor
options.Middlewares.Add(new AuditingMiddlewareConfiguration
{
Contributors =
{
new AuditingMiddlewareContributor(typeof(SelectiveGetAuditingMatcher))
}
});
});
}
Notes:
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.
Workarounds you can apply immediately:
Notes:
Status:
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.
Try these, in order:
RouterModule.forRoot(routes, { onSameUrlNavigation: 'ignore' })
@Injectable({ providedIn: 'root' })
export class ManageProfileFormState {
form = this.fb.group({
userName: [''],
email: [''],
name: [''],
surname: [''],
phoneNumber: [''],
});
constructor(private fb: FormBuilder) {}
}
@Component({ /* account manage tab component */ })
export class PersonalInfoTabComponent {
form = this.state.form;
constructor(private state: ManageProfileFormState) {}
}
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.
What you observe is not an ABP feature. ABP Angular apps are standard Angular SPAs. Resizing the browser (switching between desktop/mobile widths) should not reload the route or recreate your page component by itself. If your form loses state, it’s typically caused by one of these in your Angular app:
How to fix:
// app.component.ts (or any global service)
@HostListener('window:resize', ['$event'])
onResize() {
// Do NOT call location.reload() or window.location.href changes here.
// Do NOT call router.navigate(...) here just for responsive behavior.
}
RouterModule.forRoot(routes, { onSameUrlNavigation: 'ignore' })
Reference: Angular Router docs for onSameUrlNavigation.
// Keep form in a service to preserve state across template swaps
@Injectable({ providedIn: 'root' })
export class MyFormState {
form = this.fb.group({ name: [''], /* ... */ });
constructor(private fb: FormBuilder) {}
}
@Component({...})
export class MyPageComponent {
form = this.state.form; // bind same instance
constructor(private state: MyFormState) {}
}
Make sure no breakpoint observer or theme code triggers navigation:
Quick checklist:
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.
Goal: https://localhost:44320/api/auth should be the app’s base URL. Key rule: When you use app.UsePathBase("/api/auth"), every incoming request path and every generated URL must include /api/auth.
Apply these steps to your HttpApi.Host:
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UsePathBase("/api/auth");
app.UseRouting();
app.UseStaticFiles();
app.UseAbpStudioLink();
app.UseAbpSecurityHeaders();
app.UseCors();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseUnitOfWork();
app.UseDynamicClaims();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
// Swagger endpoint MUST include the PathBase prefix
options.SwaggerEndpoint("/api/auth/swagger/v1/swagger.json", "API");
// And make Swagger UI itself available under /api/auth/swagger
options.RoutePrefix = "api/auth/swagger";
});
app.UseConfiguredEndpoints();
}
{
"App": {
"SelfUrl": "https://localhost:44320/api/auth"
}
}
ABP uses App:SelfUrl for various generated links. If you keep it without the prefix, some URLs will be wrong.
Keep controller routes as-is You do NOT need to change [Route("api/...")] attributes or conventional controller prefixes. PathBase sits in front of the entire app, so /api/auth/api/values would be wrong. Correct request is /api/auth/api/values, which is “/api/auth” (PathBase) + “/api/values” (your controller route). Don’t double-prefix routes.
Swagger JSON endpoint path With PathBase, the JSON is served at /api/auth/swagger/v1/swagger.json. Ensure:
Anti-forgery and ABP Swagger UI script ABP’s Swagger integration injects abp.js to handle CSRF. With PathBase, the SetCsrfCookie endpoint will resolve correctly as long as App:SelfUrl and PathBase are consistent and the Swagger UI page is under the same PathBase.
If you also expose static assets under the same site Call app.UseStaticFiles() after UsePathBase so static files are served via /api/auth/… when requested from this host.
Common pitfalls that cause 404 in Swagger:
Optional (only if you must run the UI at root /swagger while API is under /api/auth):
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.
Where to see logs during development
How to confirm or change the file location
Increasing verbosity to capture errors
Production recommendations
Quick checklist
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.