using BlazorApp.Data; using BlazorApp.Shared; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Syncfusion.Blazor; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.AspNetCore.Components.Server; using Radzen; using Blazored.SessionStorage; using BlazorApp.Helper; using Microsoft.AspNetCore.Http; namespace BlazorApp { public class ThemeState { public string CurrentTheme { get; set; } = "default"; } public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddDbContext(options => options.UseSqlServer( Configuration.GetConnectionString("BlazorAppContextConnection"))); services.AddDefaultIdentity() .AddRoles() .AddEntityFrameworkStores(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddBlazoredSessionStorage(); //services.AddScoped(); // services.AddAuthentication("Identity.Application") //.AddCookie(); services.AddControllers(); #region Localization // Set the resx file folder path to access services.AddLocalization(options => options.ResourcesPath = "Resources"); services.AddSyncfusionBlazor(); // Register the Syncfusion locale service to customize the SyncfusionBlazor component locale culture services.AddSingleton(typeof(ISyncfusionStringLocalizer), typeof(SyncfusionLocalizer)); services.Configure(options => { // Define the list of cultures your app will support var supportedCultures = new List() { new CultureInfo("en-US"), new CultureInfo("de"), new CultureInfo("fr-CH"), new CultureInfo("zh") }; // Set the default culture options.DefaultRequestCulture = new RequestCulture("en-US"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); #endregion services.AddRazorPages(); services.AddServerSideBlazor(); services.AddSingleton(); services.AddSingleton(typeof(ISyncfusionStringLocalizer), typeof(SyncfusionLocalizer)); services.AddSyncfusionBlazor(); //Radzen services.AddScoped(); services.AddScoped(); services.AddScoped(); // services.AddScoped(); services.AddProtectedBrowserStorage(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("@31392e332e30fiDefXUOcJO49JmXhgG2Hsyqek3O7OMX/3FKEUOUU9I="); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } 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.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); app.UseFastReport(); } private async Task DeveloperLogin(HttpContext httpContext) { var UserManager = httpContext.RequestServices.GetRequiredService>(); var signInManager = httpContext.RequestServices.GetRequiredService>(); var _user = await UserManager.FindByNameAsync("info@shub.ch"); await signInManager.SignInAsync(_user, isPersistent: false); } } }