I created a simple ASP.NET page that calls "SELECT * FROM Products" against a local instance of the Northwind database, fills a DataSet with the result, and binds it to a DataGrid. To limit the web server overhead, I disabled ViewState and SessionState on the page. The page's code without caching was as follows:
Default.aspx
<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="MicroCache._Default" EnableSessionState="false" EnableViewState="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Products</title>
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
</form>
</body>
</HTML>
The codebehind performed the logic as follows:
Default.aspx.cs (excerpt)
public class _Default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
BindGrid();
}
private void BindGrid()
{
SqlConnection conn = new SqlConnection("server=localhost;database=northwind;integrated security=true");
SqlDataAdapter cmd = new SqlDataAdapter("SELECT * FROM Products", conn);
DataSet ds = new DataSet("Products");
cmd.Fill(ds);
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
}
...
}