Skip to content

Commit

Permalink
Abandon Startup.cs (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScarletKuro authored Nov 15, 2024
1 parent aaa20db commit 34f7d44
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 70 deletions.
46 changes: 39 additions & 7 deletions src/TryMudBlazor.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
using MudBlazor.Examples.Data;

namespace TryMudBlazor.Server;

public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<IPeriodicTableService, PeriodicTableService>();
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
webBuilder.UseStartup<Startup>();
policy.WithOrigins("https://www.mudblazor.com", "https://mudblazor.com");
});
});
builder.Services.AddControllers();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebAssemblyDebugging();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();

app.UseRouting();

app.UseCors();

// Needed for wasm project
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();

app.MapControllers();
app.MapFallbackToFile("index.html");

app.Run();
}
}
63 changes: 0 additions & 63 deletions src/TryMudBlazor.Server/Startup.cs

This file was deleted.

0 comments on commit 34f7d44

Please sign in to comment.