public void Configure(IApplicationBuilder app, IHostingEnvironment env, OptionsValidator optionsValidator, IServiceProvider serviceProvider) { if (optionsValidator == null) { throw new ArgumentNullException(nameof(optionsValidator)); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } optionsValidator.Validate(); serviceProvider.GetService <IMachineLiveDataService>().RegisterHubAsync(); app.Use(async(context, next) => { var path = context.Request.Path; if (!path.StartsWithSegments("/api", StringComparison.Ordinal) && !path.StartsWithSegments("/hubs", StringComparison.Ordinal) && !Path.HasExtension(path)) { context.Request.Path = "/index.html"; _logger.LogInformation("Rerouting from {SourceRoute} to {DestinationRoute}", path, context.Request.Path); } await next(); }); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseHttpsRedirection(); app.UseSignalR(routes => { routes.MapHub <MachineLiveDataHub>("/hubs/machineLiveData"); }); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. #pragma warning disable S2325 // Methods and properties that don't access instance data should be static public void Configure(IApplicationBuilder app, IHostingEnvironment env, OptionsValidator optionsValidator) #pragma warning restore S2325 // Methods and properties that don't access instance data should be static { if (optionsValidator == null) { throw new ArgumentNullException(nameof(optionsValidator)); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } optionsValidator.Validate(); app.Use(async(context, next) => { var path = context.Request.Path; if (!path.StartsWithSegments("/api", StringComparison.Ordinal) && !path.StartsWithSegments("/hubs", StringComparison.Ordinal) && !Path.HasExtension(path)) { context.Request.Path = "/index.html"; } await next(); }); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseHttpsRedirection(); app.UseMvc(); }