public ChatHub(CatchmeContext context, catchmebgContext bgContext) { _context = context; _bgContext = bgContext; AllUsers = _bgContext.Users.Select(u => new UserDetail() { ConnectionId = "", UserName = u.UserName }).ToList(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, catchmebgContext db1, CatchmeContext db2) { // run the migrations before other code db1.Database.Migrate(); db2.Database.Migrate(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseFileServer(); app.UseWebSockets(); app.UseSignalR(routes => { routes.MapHub <ChatHub>("/hubs/chat"); }); //app.UseMvc(routes => //{ // routes.MapRoute( // name: "default", // template: "{controller=Home}/{action=Index}/{id?}"); //}); app.UseMvc(routes => { routes.MapRoute( name: "areas", template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); routes.MapAreaRoute( name: "default", areaName: "Main", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public HomeController(catchmebgContext context, IHostingEnvironment environment) { _context = context; _environment = environment; }