You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingSampleApp.Options;usingMicrosoft.AspNetCore.Builder;usingMicrosoft.AspNetCore.Hosting;usingMicrosoft.Extensions.Configuration;usingMicrosoft.Extensions.DependencyInjection;usingMicrosoft.Extensions.Hosting;namespaceSampleApp{publicclassStartup{publicIConfigurationConfiguration{get;}publicStartup(IConfigurationconfiguration){Configuration=configuration;}// 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=398940publicvoidConfigureServices(IServiceCollectionservices){services.AddOptions<SampleOptions>().Bind(Configuration.GetSection(SampleOptions.ConfigSectionName)).ValidateDataAnnotations();services.AddRazorPages();services.AddServerSideBlazor();services.AddSingleton<WeatherForecastService>();}// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.publicvoidConfigure(IApplicationBuilderapp,IWebHostEnvironmentenv){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.UseEndpoints(endpoints =>{endpoints.MapBlazorHub();endpoints.MapFallbackToPage("/_Host");});}}}
When executing the code, I would expect an OptionsValidationException being thrown on application startup if I have bad option values set in my appsetting.json file.
But when I start my Blazor server application, nothing happens !!!
The text was updated successfully, but these errors were encountered:
Here is a sample options class.
Below is code used in Startup class.
When executing the code, I would expect an OptionsValidationException being thrown on application startup if I have bad option values set in my appsetting.json file.
But when I start my Blazor server application, nothing happens !!!
The text was updated successfully, but these errors were encountered: