All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASP.NET2.0缓存(Cache)技术_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/10 6:25:04 Browse times: 362 Comment times: 0

ASP.NET2.0缓存(Cache)技术_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

ASP.NET2.0缓存(Cache)技术_[Asp.Net教程] ASP.NET 2.0提供了一些新的用于提升程序性能的技术特性,其中,缓存技术是非常重要的一个特性,它提供了一种非常好的本地数据缓存机制,可以非常容易的定制属于数据缓从,从而有效的提高数据访问的性能。

经试验,觉得自定义控件中加入缓存,从而实现整个页的局部缓存,效果不错。

自定义控件在前台加入:

<%@ OutputCache Duration="60" VaryByParam="none" %>

后台代码:

protected void Page_Load(object sender, EventArgs e)
...{
Label1.Text = DateTime.Now.ToString();

source = (DataView)Cache["SQUARE"];

if (source == null)
...{
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GoConnectionString"].ConnectionString);
mycmd = new SqlDataAdapter("select * from GUser", conn);

DataSet ds = new DataSet();

mycmd.Fill(ds, "GUser");

source = new DataView(ds.Tables["GUser"]);

Cache["SQUARE"] = source;

}
else
...{

}

GridView1.DataSource = source;
GridView1.DataBind();
} 来源:CSDN




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.