Last active
July 21, 2018 19:41
-
-
Save sfmskywalker/b4a3791b519566e099171a1283117d9b to your computer and use it in GitHub Desktop.
Startup with custom configuration
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
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.DependencyInjection; | |
using OrchardCore.Environment.Shell; | |
namespace MultiTenantApp | |
{ | |
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services | |
.AddOrchardCore() | |
.WithTenants(); | |
} | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
app.UseOrchardCore(a => a.Run(async context => | |
{ | |
// ShellSettings provide the tenant's configuration. | |
var shellSettings = context.RequestServices.GetRequiredService<ShellSettings>(); | |
// Read the tenant-specific custom setting. | |
var customSetting = shellSettings.Configuration["CustomSetting"]; | |
// Write the value of the custom setting to the response stream. | |
await context.Response.WriteAsync(customSetting); | |
})); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment