Refaktorierte HomeController, um standardmäßig das Culture-Cookie zu setzen, falls es fehlt, und die Kultur aus den übergebenen Query-Parametern zu übernehmen.
This commit is contained in:
@@ -71,8 +71,7 @@ try
|
||||
|
||||
//AddEF Core dbcontext
|
||||
var connStr = config["Config:ConnectionString"];
|
||||
builder.Services.AddDbContext<EGDbContext>(options =>
|
||||
options.UseSqlServer(connStr));
|
||||
builder.Services.AddDbContext<EGDbContext>(options => options.UseSqlServer(connStr));
|
||||
|
||||
//Inject CRUD Service and repositoriesad
|
||||
builder.Services.AddScoped<IConfigRepository, ConfigRepository>();
|
||||
@@ -156,7 +155,7 @@ try
|
||||
|
||||
builder.Services.AddCookieConsentSettings();
|
||||
|
||||
builder.Services.AddCookieBasedLocalizer("Resources");
|
||||
builder.Services.AddCookieBasedLocalizer();
|
||||
|
||||
builder.Services.AddSingleton(HtmlEncoder.Default);
|
||||
builder.Services.AddSingleton(UrlEncoder.Default);
|
||||
@@ -207,7 +206,7 @@ try
|
||||
app.UseAuthorization();
|
||||
|
||||
var cultures = app.Services.GetRequiredService<Cultures>();
|
||||
if(cultures.Any())
|
||||
if(!cultures.Any())
|
||||
throw new InvalidOperationException(@"Languages section is missing in the appsettings. Please configure like following.
|
||||
Language is both a name of the culture and the name of the resx file such as Resource.de-DE.resx
|
||||
FIClass is the css class (in wwwroot/lib/flag-icons-main) for the flag of country.
|
||||
|
||||
Reference in New Issue
Block a user