-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
159 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-dotnettools.csharp", | ||
"formulahendry.dotnet-test-explorer", | ||
"editorconfig.editorconfig", | ||
"shd101wyy.markdown-preview-enhanced", | ||
"davidanson.vscode-markdownlint", | ||
"editorconfig.editorconfig", | ||
"formulahendry.dotnet-test-explorer", | ||
"ms-dotnettools.csharp", | ||
"stkb.rewrap" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"ASPNETCORE_URLS": "http://localhost:5555" | ||
}, | ||
"launchBrowser": { | ||
"enabled": false | ||
}, | ||
"name": "Sandbox 2.1-2.2", | ||
"preLaunchTask": "build", | ||
"program": "${workspaceFolder}/samples/Sandbox.AspNetCore2_1_To_2_2/bin/Debug/netcoreapp2.1/Sandbox.AspNetCore2_1_To_2_2.dll", | ||
"request": "launch", | ||
"stopAtEntry": false, | ||
"type": "coreclr" | ||
}, | ||
{ | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"ASPNETCORE_URLS": "http://localhost:5555" | ||
}, | ||
"launchBrowser": { | ||
"enabled": false | ||
}, | ||
"name": "Sandbox 2-3.1", | ||
"preLaunchTask": "build", | ||
"program": "${workspaceFolder}/samples/Sandbox.AspNetCore3_To_3_1/bin/Debug/netcoreapp3.1/Sandbox.AspNetCore3_To_3_1.dll", | ||
"request": "launch", | ||
"stopAtEntry": false, | ||
"type": "coreclr" | ||
}, | ||
{ | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"ASPNETCORE_URLS": "http://localhost:5555" | ||
}, | ||
"launchBrowser": { | ||
"enabled": false | ||
}, | ||
"name": "Sandbox 5-6", | ||
"preLaunchTask": "build", | ||
"program": "${workspaceFolder}/samples/Sandbox.AspNetCore5_To_6/bin/Debug/net6.0/Sandbox.AspNetCore5_To_6.dll", | ||
"request": "launch", | ||
"stopAtEntry": false, | ||
"type": "coreclr" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"cSpell.words": [ | ||
"autofac", | ||
"multitenant" | ||
], | ||
"dotnet-test-explorer.runInParallel": true, | ||
"dotnet-test-explorer.testProjectPath": "test/**/*.Test.csproj" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Sample ASP.NET Core Multitenant Applications | ||
|
||
Each of the 'sandbox' applications shows, in the respective framework version, the functionality of Autofac.AspNetCore.Multitenant in action. You can launch them from Visual Studio or VS Code with the settings in this project; or you can run from the command line with `dotnet run`. | ||
|
||
## Try It Out | ||
|
||
You can see different dependencies used by querying the `api/values` route: | ||
|
||
```sh | ||
# Get the default value - will show `base` since there's no tenant ID. | ||
curl http://localhost:5555/api/values | ||
|
||
# Get some tenant-specific values - will show the tenant ID due to overrides. | ||
curl http://localhost:5555/api/values?tenant=a | ||
curl http://localhost:5555/api/values?tenant=b | ||
|
||
# Only tenant a and b have overrides. Tenant c will show `base` again. | ||
curl http://localhost:5555/api/values?tenant=c | ||
``` | ||
|
||
## Points of Interest | ||
|
||
### Program.cs | ||
|
||
When using the `WebHostBuilder` the `UseAutofacMultitenantRequestServices` extension is used to tie the multitenant container to the request lifetime scope generation process. | ||
|
||
**If you comment out the `UseAutofacMultitenantRequestServices` line it'll stop working** and you'll only ever see `base`. This illustrates why this package is required. | ||
|
||
## Startup.cs | ||
|
||
In `ConfigureServices` we... | ||
|
||
- Create a tenant ID strategy. | ||
- Set up the multitenant container. | ||
- Store the multitenant container in a place that the request services middleware can access it later. | ||
- Return an `AutofacServiceProvider` so services can be resolved normally. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
samples/Sandbox.AspNetCore2_1_To_2_2/Sandbox.AspNetCore2_1_To_2_2.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
samples/Sandbox.AspNetCore3_To_3_1/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"Sandbox.Sandbox.AspNetCore3_To_3_1": { | ||
"applicationUrl": "http://localhost:5555", | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"launchUrl": "api/values", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "http://localhost:35115" | ||
"launchBrowser": true, | ||
"launchUrl": "api/values" | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
7 changes: 4 additions & 3 deletions
7
...spNetCore5/Properties/launchSettings.json → ...Core5_To_6/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"Sandbox.AspNetCore5": { | ||
"applicationUrl": "http://localhost:5555", | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"launchUrl": "api/values", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "http://localhost:35116" | ||
"launchBrowser": true, | ||
"launchUrl": "api/values" | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ox.AspNetCore5/Sandbox.AspNetCore5.csproj → ...ore5_To_6/Sandbox.AspNetCore5_To_6.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.