You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/Overview-Angular.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,8 @@ There may be other ways of doing it but this is the simplest way.
109
109
110
110
> Inthedevelopmenttime, youdon't need to use subdomains for tenants for a simpler development experience. When you do like that, a 'tenantswitch' dialog is used to manually switch between tenants.
111
111
112
+
> For advanced scenarios and production-level configuration of subdomain-based multi-tenancy in ASP.NET Zero Angular applications, including SSL setup, IIS configuration, local development strategies, and tenant resolution internals, please refer to the extended documentation here: [Subdomain-Based Multi-Tenancy in ASP.NET Zero (Angular)](Subdomain-Based-Multi-Tenancy-Angular.md)
113
+
112
114
Check out the [multi tenant documentation](https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy) if you are building multi-tenant applications.
Copy file name to clipboardExpand all lines: docs/en/Overview-Core.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,8 @@ There may be other ways of doing it but this is the simplest way.
87
87
88
88
> Inthedevelopmenttime, youdon't need to use subdomains for tenants for a simpler development experience. When you do like that, a 'tenantswitch' dialog is used to manually switch between tenants.
89
89
90
+
> For advanced scenarios and production-level configuration of subdomain-based multi-tenancy in ASP.NET Zero MVC applications, including SSL setup, IIS configuration, local development strategies, and tenant resolution internals, please refer to the extended documentation here: [Subdomain-Based Multi-Tenancy in ASP.NET Zero (MVC)](Subdomain-Based-Multi-Tenancy-MVC.md)
91
+
90
92
Check out the [multi tenant documentation](https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy) if you are building multi-tenant applications.
91
93
92
94
Similarto**WebSiteRootAddress**, **ServerRootAddress**settingisalsoexistsin `appsettings.json` in .Web.Hostproject.
Copy file name to clipboardExpand all lines: docs/en/Subdomain-Based-Multi-Tenancy-Angular.md
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# Subdomain-Based Multi-Tenancy in ASP.NET Zero (Angular)
1
+
# SubdomainBased MultiTenancy in ASP.NET Zero (Angular)
2
2
3
3
## Introduction
4
4
5
-
This document provides detailed guidance for configuring and troubleshooting subdomain based multi-tenancy in ASP.NET Zero projects utilizing an Angular frontend. It expands upon the foundational knowledge offered in the official documentation, aiming to cover advanced configurations, development environment strategies, and common issues.
5
+
This document provides detailed guidance for configuring and troubleshooting subdomain based multitenancy in ASP.NET Zero projects utilizing an Angular frontend. It expands upon the foundational knowledge offered in the official documentation, aiming to cover advanced configurations, development environment strategies, and common issues.
6
6
7
7
This document assumes you have a basic understanding of ASP.NET Zero's multi tenancy concepts and have reviewed the main [Overview Angular](Overview-Angular.md) documentation.
8
8
9
-
## 1. Configuration for Subdomain-Based Tenancy
9
+
## 1. Configuration for SubdomainBased Tenancy
10
10
11
11
This section involves SSL management, web server setup, and specific Angular application settings.
12
12
@@ -26,7 +26,7 @@ This section involves SSL management, web server setup, and specific Angular app
26
26
* For HTTP binding (port 80), you can often leave the "Host Name" field empty if it's the only site on that IP, or specify each primary domain if needed.
27
27
* For HTTPS binding (port 443), select the appropriate wildcard SSL certificate. The host name field might be left blank or set if your IIS version supports specific SNI configurations with wildcards, but often the wildcard nature is primarily handled by the certificate itself. The key is that IIS listens for traffic on the IP and port, and the certificate validates for `*.mydomain.com`.
28
28
***Default Document/Application:** Ensure your IIS site is configured to correctly serve the Angular application (typically `index.html` and other static assets from your `dist` folder) for all subdomain requests that point to the client application.
29
-
***URL Rewrite (If Necessary):** While ASP.NET Zero's framework handles tenant resolution based on the host, complex infrastructures involving reverse proxies might require URL Rewrite rules. However, for standard deployments, this is generally not needed for the core multi-tenancy functionality.
29
+
***URL Rewrite (If Necessary):** While ASP.NET Zero's framework handles tenant resolution based on the host, complex infrastructures involving reverse proxies might require URL Rewrite rules. However, for standard deployments, this is generally not needed for the core multitenancy functionality.
@@ -43,13 +43,13 @@ This section involves SSL management, web server setup, and specific Angular app
43
43
}
44
44
```
45
45
* **Tenant Resolution in Angular:**
46
-
* ASP.NET Zero's client-side infrastructure typically uses the `ServerRootAddress`. The framework includes logic to dynamically replace the `{TENANCY_NAME}` placeholder based on the current browser URL's subdomain.
46
+
* ASP.NET Zero's clientside infrastructure typically uses the `ServerRootAddress`. The framework includes logic to dynamically replace the `{TENANCY_NAME}` placeholder based on the current browser URL's subdomain.
47
47
* This ensures that API calls generated by `NSwag` or other service proxies are directed to the correct tenant specific backend endpoints.
48
-
* While largely abstracted, the Angular application inherently becomes tenant-aware through these configured, dynamic URLs.
48
+
* While largely abstracted, the Angular application inherently becomes tenantaware through these configured, dynamic URLs.
49
49
50
50
## 2. Development Environment Strategies for Subdomain Testing
51
51
52
-
Testing subdomain-based multi-tenancy locally requires a few extra steps compared to path-based tenancy or using the tenant switch dialog.
52
+
Testing subdomainbased multitenancy locally requires a few extra steps compared to pathbased tenancy or using the tenant switch dialog.
53
53
54
54
### Using the `hosts` File
55
55
@@ -77,7 +77,7 @@ Testing subdomain-based multi-tenancy locally requires a few extra steps compare
77
77
78
78
* Standard `localhost` development certificates provided by `dotnet dev-certs https` will not be valid for custom local subdomains like `tenant1.localhost`. This will result in browser SSL warnings.
79
79
* **Solutions:**
80
-
1. **HTTP Locally:** For simplicity, you can develop and test the subdomain logic using HTTP locally and rely on the tenant switch dialog if HTTPS-specific features are not being tested.
80
+
1. **HTTP Locally:** For simplicity, you can develop and test the subdomain logic using HTTP locally and rely on the tenant switch dialog if HTTPSspecific features are not being tested.
81
81
2. **`mkcert` Tool:** Use a tool like `mkcert` to create a locally trusted Certificate Authority (CA) and then generate wildcard certificates (e.g., `*.localhost`). You would then configure Kestrel and potentially the Angular dev server to use these certificates. This provides a more accurate simulation of a production HTTPS environment.
82
82
83
83
### Interaction with Tenant Switch Dialog
@@ -87,37 +87,37 @@ Testing subdomain-based multi-tenancy locally requires a few extra steps compare
87
87
88
88
## 3. Tenant Resolution Flow Clarification
89
89
90
-
A clear understanding of the tenant resolution process is essential to ensure accurate tenant identification and proper request routing in a multi-tenant architecture. This step determines which tenant context should be applied based on the incoming request, typically using elements like the subdomain, header, or query string.
90
+
A clear understanding of the tenant resolution process is essential to ensure accurate tenant identification and proper request routing in a multitenant architecture. This step determines which tenant context should be applied based on the incoming request, typically using elements like the subdomain, header, or query string.
91
91
92
92
### Backend (ASP.NET Core)
93
93
94
94
1. An incoming HTTP request arrives at the ASP.NET Core application.
95
95
2. ASP.NET Zero's middleware, specifically implementations of `ITenantResolveContributor` (like `DomainTenantResolveContributor`), inspects the request's host header (e.g., `tenant1.api.mydomain.com`).
96
96
3. If the host matches the configured subdomain pattern (derived from `ServerRootAddress` with the `{TENANCY_NAME}` placeholder), the middleware extracts the tenancy name (`tenant1` in this example).
97
97
4. It then attempts to find this tenant in the database.
98
-
5. If found, the current tenant context is set for the duration of that request, ensuring data isolation and that tenant-specific settings and services are used.
98
+
5. If found, the current tenant context is set for the duration of that request, ensuring data isolation and that tenantspecific settings and services are used.
99
99
100
100
### Frontend (Angular)
101
101
102
102
1. The Angular application is loaded from a URL like `https://tenant1.app.mydomain.com`.
103
103
2. The `ServerRootAddress` in `appsettings.json` (e.g., `https://{TENANCY_NAME}.api.mydomain.com`) is used by the generated service proxies.
104
-
3. ASP.NET Zero's client-side JavaScript utilities dynamically replace the `{TENANCY_NAME}` placeholder in `ServerRootAddress` with the actual tenancy name extracted from the current browser window's hostname (`tenant1.app.mydomain.com`).
105
-
4. All subsequent API calls made through these service proxies will correctly target the tenant-specific backend API endpoints (e.g., `https://tenant1.api.mydomain.com/api/services/app/User/GetUsers`).
104
+
3. ASP.NET Zero's clientside JavaScript utilities dynamically replace the `{TENANCY_NAME}` placeholder in `ServerRootAddress` with the actual tenancy name extracted from the current browser window's hostname (`tenant1.app.mydomain.com`).
105
+
4. All subsequent API calls made through these service proxies will correctly target the tenantspecific backend API endpoints (e.g., `https://tenant1.api.mydomain.com/api/services/app/User/GetUsers`).
106
106
107
-
## 4. Troubleshooting Common Subdomain Multi-Tenancy Issues
107
+
## 4. Troubleshooting Common Subdomain MultiTenancy Issues
108
108
109
109
Here are some common problems and how to address them:
110
110
111
111
### DNS Not Resolving
112
112
113
113
* **Propagation Time:** DNS changes (especially for new wildcard records) can take time to propagate globally (minutes to hours).
114
-
* **Record Verification:** Double-check your DNS provider's settings. Ensure the `A` record or `CNAME` record for the wildcard (e.g., `*.mydomain.com`) correctly points to your web server's public IP address.
114
+
* **Record Verification:** Doublecheck your DNS provider's settings. Ensure the `A` record or `CNAME` record for the wildcard (e.g., `*.mydomain.com`) correctly points to your web server's public IP address.
115
115
* **Local `hosts` File:** For local development, ensure your `hosts` file entries are correctly spelled, saved, and that your browser or OS is not caching old DNS lookups aggressively (try clearing cache or an incognito window).
116
116
117
117
### CORS Errors
118
118
119
119
* **CorsOrigins Configuration:** In the `appsettings.json` of your `*.Web.Host` project, meticulously check the `App:CorsOrigins` setting. It must accurately include the URLs of your Angular application, including the wildcard for subdomains.
120
-
* Example: `"CorsOrigins": "https://*.app.mydomain.com,http://*.app.mydomain.com"` (include both HTTP and HTTPS if applicable, and consider ports if non-standard).
120
+
* Example: `"CorsOrigins": "https://*.app.mydomain.com,http://*.app.mydomain.com"` (include both HTTP and HTTPS if applicable, and consider ports if nonstandard).
121
121
* **Browser Console:** Always inspect the browser's developer console (Network tab) for detailed CORS error messages. The error often indicates which origin is being blocked and what headers are missing or mismatched from the preflight (OPTIONS) request.
122
122
* **Scheme and Port:** CORS is sensitive to scheme (HTTP vs. HTTPS) and port numbers. Ensure these match exactly in your `CorsOrigins` configuration.
123
123
@@ -127,7 +127,7 @@ Here are some common problems and how to address them:
127
127
* Ensure your certificate is a true wildcard (e.g., `*.mydomain.com`) or a SAN certificate that explicitly lists all required tenant subdomains or the relevant wildcard.
128
128
* **Untrusted Certificate:**
129
129
* For production, ensure your certificate is issued by a reputable CA.
130
-
* For local development with self-signed or `mkcert`-generated certificates, ensure the root CA certificate used to sign them is trusted by your operating system and browser.
130
+
* For local development with selfsigned or `mkcert`generated certificates, ensure the root CA certificate used to sign them is trusted by your operating system and browser.
131
131
* **Mixed Content:** Ensure all resources are loaded over HTTPS if your site is HTTPS.
0 commit comments