-
Notifications
You must be signed in to change notification settings - Fork 114
/
Program.cs
51 lines (38 loc) · 1.54 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using BlazorServerApp.Data;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.FeatureManagement;
namespace BlazorServerApp
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie();
builder.Services.AddScoped<UserAgentContext>();
//
// To consume scoped services, AddScopedFeatureManagement should be used instead of AddFeatureManagement.
// This will ensure that feature management services, including feature filters, targeting context accessor, are added as scoped services.
builder.Services.AddScopedFeatureManagement()
.WithTargeting<MyTargetingContextAccessor>()
.AddFeatureFilter<BrowserFilter>();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();
}
}
}