You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WF-WebAdmin/WF-WebAdmin/WF-WebAdmin/Program.cs

87 lines
2.4 KiB

using Blazorise;
using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Localization;
using System.Globalization;
using WF_WebAdmin.Data;
using WF_WebAdmin.Model;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using Blazored.Modal;
using WF_WebAdmin.Service;
[assembly: RootNamespace("WF_WebAdmin")]
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddHttpClient();
builder.Services.AddScoped<UserLogin>();
builder.Services
.AddBlazorise()
.AddBootstrapProviders()
.AddHttpClient()
.AddFontAwesomeIcons();
builder.Services.AddBlazoredModal();
// Add the controller of the app
builder.Services.AddControllers();
// Add the localization to the app and specify the resources path
builder.Services.AddLocalization(opts => { opts.ResourcesPath = "Resources"; });
// Configure the localtization
builder.Services.Configure<RequestLocalizationOptions>(options =>
{
var supportedCultures = new[] { "en-US", "fr-FR" };
options.DefaultRequestCulture = new RequestCulture(new CultureInfo("en-US"));
options.SupportedCultures = supportedCultures.Select(c=>new CultureInfo(c)).ToList();
options.SupportedUICultures = supportedCultures.Select(c => new CultureInfo(c)).ToList();
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
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.UseStaticFiles();
app.UseRouting();
// Get the current localization options
var options = ((IApplicationBuilder)app).ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
if (options?.Value != null)
{
// use the default localization
app.UseRequestLocalization(options.Value);
}
// Add the controller to the endpoint
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();