-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathProgram.cs
38 lines (30 loc) · 1.18 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
using AspNetCoreDashboardBackend.Code;
using DevExpress.AspNetCore;
using DevExpress.DashboardAspNetCore;
using DevExpress.DashboardWeb;
using Microsoft.Extensions.FileProviders;
var builder = WebApplication.CreateBuilder(args);
IFileProvider? fileProvider = builder.Environment.ContentRootFileProvider;
IConfiguration? configuration = builder.Configuration;
// Configures services to use the Web Dashboard Control.
builder.Services.AddCors(options => {
options.AddPolicy("CorsPolicy", builder => {
builder.AllowAnyOrigin();
builder.AllowAnyMethod();
builder.WithHeaders("Content-Type");
});
});
builder.Services.AddDevExpressControls();
builder.Services.AddControllers();
builder.Services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
return DashboardUtils.CreateDashboardConfigurator(configuration, fileProvider);
});
var app = builder.Build();
app.UseDevExpressControls();
app.UseRouting();
app.UseCors("CorsPolicy");
// Maps the dashboard route.
app.MapDashboardRoute("api/dashboard", "DefaultDashboard");
// Requires CORS policies.
app.MapControllers().RequireCors("CorsPolicy");
app.Run();