feat: map controllers

This commit is contained in:
Oliver Booth 2023-08-05 21:01:47 +01:00
parent 057c22d9a7
commit bb4a0238be
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61
1 changed files with 6 additions and 0 deletions

View File

@ -1,9 +1,13 @@
using System.Globalization;
using Microsoft.AspNetCore.Localization;
using OliverBooth;
using OliverBooth.Middleware;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
builder.Services.AddRazorPages().AddViewLocalization().AddDataAnnotationsLocalization();
builder.Services.AddControllersWithViews();
builder.Services.AddRouting(options => options.LowercaseUrls = true);
var supportedCultures = new[]
@ -42,6 +46,8 @@ app.UseRequestLocalization(options =>
options.SupportedUICultures = supportedCultures;
options.RequestCultureProviders.Insert(0, new RouteCultureProvider(supportedCultures[0]));
});
app.MapControllers();
app.UseCultureRedirect();
app.MapControllerRoute("default", "{culture=en}/{controller=Home}/{action=Index}/{id?}");
app.MapRazorPages();