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

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.