public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseSetting(WebHostDefaults.PreventHostingStartupKey, "true") .UseKestrel(options => { options.Listen(EnvSettings.Instance().IP, EnvSettings.Instance().Port); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup <Startup>() .Build();
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); // Sockets //app.UseCors("Everything"); app.UseCors(builder => builder.WithOrigins(EnvSettings.Instance().WebPortalUrl) .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); app.UseSignalR(routes => { routes.MapHub <ChatHub>("chat"); routes.MapHub <StockDiscussionHub>("stockDiscussion"); }); app.UseSockets(routes => { routes.MapEndPoint <MessagesEndPoint>("chat/ws"); }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); // Autoregister using server.Features (does not work in reverse proxy mode) app.UseConsulRegisterService(); }