0

I have show notification or alert on asp.net page based on database server data insertion, so I want to know if it is possible to do this task by push models?

1 Answer 1

1

You can use SignalR to send notifications from your web server to your clients: http://signalr.net/.

To send notifications from SQL Server to your web server, you can use the SqlDependency and SqlCacheDependency classes.

From the guidelines, http://msdn.microsoft.com/en-US/library/9dz445ks(v=vs.110).aspx,

SqlDependency.Start(myConnectionString);

using (SqlConnection connection = new SqlConnection(myConnectionString))
{
    using (SqlCommand command = new SqlCommand("SELECT ... FROM MyTable", connection))
    {
        SqlCacheDependency dependency = new SqlCacheDependency(command);
        // Refresh the cache after the number of minutes
        // listed below if a change does not occur.
        // This value could be stored in a configuration file.
        int numberOfMinutes = 3;
        DateTime expires = DateTime.Now.AddMinutes(numberOfMinutes);

        Response.Cache.SetExpires(expires);
        Response.Cache.SetCacheability(HttpCacheability.Public);
        Response.Cache.SetValidUntilExpires(true);

        Response.AddCacheDependency(dependency);

        connection.Open();
    }
}
1
  • SqlDependency class can be used with SQL SERVER 2012? Commented Aug 16, 2013 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.