Skip to content

Instantly share code, notes, and snippets.

@sfmskywalker
Last active July 21, 2018 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfmskywalker/b4a3791b519566e099171a1283117d9b to your computer and use it in GitHub Desktop.
Save sfmskywalker/b4a3791b519566e099171a1283117d9b to your computer and use it in GitHub Desktop.
Startup with custom configuration
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