Enterprise Framework

Software Solutions in the Enterprise

How To : Microsoft : Sql Server 2012 Express : Service Broker : Subscribe Query Notifications : Enable for ASP.NET and SignalR

Sql Server 2012 Express - Service Broker - Subscribe Query Notifications

To enable SQL Server 2012 Express real time data notifications to use with ASP.NET and SignalR:

  1. Run Sql
    Documentation : Enable Query Notifications
    
    ALTER DATABASE AdventureWorks SET ENABLE_BROKER;
    
    CREATE QUEUE ContactChangeMessages;
    CREATE SERVICE ContactChangeNotifications ON QUEUE ContactChangeMessages ([http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification]);
    
    GRANT SUBSCRIBE QUERY NOTIFICATIONS TO "DomainName\Username";
    
  2. Set SQL Server Permission for IIS App Pool
    1. http://stackoverflow.com/questions/7698286/login-failed-for-user-iis-apppool-asp-net-v4-0
      1. You need to add a login to SQL Server for IIS APPPOOL\ASP.NET v4.0 and grant permissions to the database.
      2. In SSMS, under the server, expand Security, then right click Logins and select "New Login...".
      3. In the New Login dialog, enter the app pool as the login name and click "OK".
      4. You can then right click the login for the app pool, select Properties and select "User Mapping". 
      5. Check the appropriate database, and the appropriate roles. I think you could just select db_datareader and db_datawriter, 
      6. but I think you would still need to grant permissions to execute stored procedures if you do that through EF.
  3. ASP.NET SqlDependency Example:
    1. http://msdn.microsoft.com/en-us/library/9dz445ks(v=vs.110).aspx
Comments are closed