<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Untitled Page
File: Default.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.Caching;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Page created: " + DateTime.Now.ToLongTimeString());
string connStr = ConfigurationManager.ConnectionStrings["AppConnectionString1"].ConnectionString;
SqlDependency.Start(connStr);
SqlConnection connection = new SqlConnection(connStr);
SqlCommand command = new SqlCommand("Select * FROM Customers", connection);
SqlCacheDependency depends = new SqlCacheDependency(command);
connection.Open();
GridView1.DataSource = command.ExecuteReader();
GridView1.DataBind();
connection.Close();
Response.AddCacheDependency(depends);
}
}
File: Web.config