日期:2014-05-17 浏览次数:20484 次
<%@ Page Language="C#" %>
<%@ OutputCache Duration="3600" VaryByParam="none" VaryByCustom="mytest1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>测试VaryByCustom</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="<%# DateTime.Now.ToString() %>" EnableViewState="false"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "mytest1")
{
var val = context.Cache["t1"];
if (val == null)
return string.Empty;
else
&nb