When using SqlDependency without providing an options value, SqlDependency. Start () must be called prior to execution of a command added to the SqlDependency instance., providingthat
When debugging the SignalR program, an exception is prompted: When using SqlDependency without providing an options value, SqlDependency. Start () must be called prior to execution of a command added to the SqlDependency instance.
The solution is to add the following highlighted code to the Application_Start () and Application_End () methods in the Global. asax. cs file:
Using System; using System. collections. generic; using System. linq; using System. web; using System. web. mvc; using System. web. routing; using Insus. NET. dataBases; using System. data. sqlClient; namespace Insus. NET {public class MvcApplication: System. web. httpApplication {protected void Application_Start () {AreaRegistration. registerAllAreas (); RouteConfig. registerRoutes (RouteTable. routes); SqlDependency. start (DB. connectionString);} protected void Application_End () {SqlDependency. stop (DB. connectionString );}}}Source Code