Как запустить sqldepndency со строкой подключения daynamic в ASP.NET MVC 5
I have some databases that work with single ASP.NET MVC project and all of the databases are the same and i used real time alarm with signalr but when i want to start sqldependencyin Application_Start method needed connection string, i set company name to cookie when user want to login and pass cookie to Application_Start to know which sqldependencyin which database started . but Application_Start run for first user,then for another user in another database i cant start sqldependency, and cookie is null in this method. please help
Что я уже пробовал:
protected void Application_Start(object sender, EventArgs e) { SqlConnectionString = ConfigurationManager.ConnectionStrings[HttpContext.Current.Request.Cookies["zone"].Value.ToString()].ConnectionString; if (!String.IsNullOrEmpty(SqlConnectionString)) { if (SqlConnectionString.ToLower().StartsWith("metadata") && SqlConnectionString != null) { System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder efbeulder = new System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder(SqlConnectionString); SqlConnectionString = efbeulder.ProviderConnectionString; SqlDependency.Start(SqlConnectionString); } } }