Skip to content

Instantly share code, notes, and snippets.

@An0d

An0d/Startup.cs Secret

Last active September 29, 2021 09:11
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 An0d/497766f14b452b278c8f4dfa3ac74c16 to your computer and use it in GitHub Desktop.
Save An0d/497766f14b452b278c8f4dfa3ac74c16 to your computer and use it in GitHub Desktop.
Umbraco9 & Hangfire with BackOffice User access
public void ConfigureServices(IServiceCollection services)
{
...
#pragma warning disable IDE0022 // Use expression body for methods
services.AddUmbraco(_env, _config)
.AddBackOffice()
.AddComposers()
.Build();
#pragma warning restore IDE0022 // Use expression body for methods
services.AddHangfireServer();
services.AddHangfire(config =>
{
config.UseSqlServerStorage(connectionString);
});
...
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseUmbraco()
.WithMiddleware(u =>
{
u.UseBackOffice();
}).WithEndpoints(u =>
{
// Hangfire url /umbraco/backoffice/hangfire
u.EndpointRouteBuilder.MapHangfireDashboardWithAuthorizationPolicy(AuthorizationPolicies.BackOfficeAccess, "/umbraco/backoffice/hangfire");
u.UseInstallerEndpoints();
u.UseBackOfficeEndpoints();
});
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment