Skip to content

Instantly share code, notes, and snippets.

@An0d

An0d/Startup.cs Secret

Last active September 29, 2021 09:06
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/46d2e5d5fab229f744669c4676adc07b to your computer and use it in GitHub Desktop.
Save An0d/46d2e5d5fab229f744669c4676adc07b to your computer and use it in GitHub Desktop.
Umbraco9 & Hangfire with Member 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.AddAuthorization(configure => configure.AddPolicy("HangfirePolicy", configurePolicy =>
{
configurePolicy.RequireAuthenticatedUser();
}));
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 /hangfire
u.EndpointRouteBuilder.MapHangfireDashboardWithAuthorizationPolicy("HangfirePolicy");
u.UseInstallerEndpoints();
u.UseBackOfficeEndpoints();
});
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment