Skip to content

Commit 34f7d44

Browse files
authored
Abandon Startup.cs (#159)
1 parent aaa20db commit 34f7d44

2 files changed

Lines changed: 39 additions & 70 deletions

File tree

src/TryMudBlazor.Server/Program.cs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,48 @@
1+
using MudBlazor.Examples.Data;
2+
13
namespace TryMudBlazor.Server;
24

35
public class Program
46
{
57
public static void Main(string[] args)
68
{
7-
CreateHostBuilder(args).Build().Run();
8-
}
9-
10-
public static IHostBuilder CreateHostBuilder(string[] args) =>
11-
Host.CreateDefaultBuilder(args)
12-
.ConfigureWebHostDefaults(webBuilder =>
9+
var builder = WebApplication.CreateBuilder(args);
10+
builder.Services.AddScoped<IPeriodicTableService, PeriodicTableService>();
11+
builder.Services.AddCors(options =>
12+
{
13+
options.AddDefaultPolicy(policy =>
1314
{
14-
webBuilder.UseStartup<Startup>();
15+
policy.WithOrigins("https://www.mudblazor.com", "https://mudblazor.com");
1516
});
17+
});
18+
builder.Services.AddControllers();
19+
20+
var app = builder.Build();
21+
22+
if (app.Environment.IsDevelopment())
23+
{
24+
app.UseDeveloperExceptionPage();
25+
app.UseWebAssemblyDebugging();
26+
}
27+
else
28+
{
29+
app.UseExceptionHandler("/Error");
30+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
31+
app.UseHsts();
32+
}
33+
app.UseHttpsRedirection();
34+
35+
app.UseRouting();
36+
37+
app.UseCors();
38+
39+
// Needed for wasm project
40+
app.UseBlazorFrameworkFiles();
41+
app.UseStaticFiles();
42+
43+
app.MapControllers();
44+
app.MapFallbackToFile("index.html");
45+
46+
app.Run();
47+
}
1648
}

src/TryMudBlazor.Server/Startup.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)