国产老熟女高潮毛片A片仙踪林,欧美喂奶吃大乳,狠狠爱无码一区二区三区,女神的私人医生动漫免费阅读

新聞建站cms系統、政府cms系統定制開發

廣州網站建設公司-閱速公司

asp.net新聞發布系統、報紙數字報系統方案
/
http://www.tjsimaide.com/
廣州網站建設公司
您當前位置:首頁>ASP.NET MVC

ASP.NET MVC

使用自定義字符串對頁的各個版本進行緩存GetVaryByCustomString

發布時間:2010/7/24 11:07:46  作者:  閱讀:1140  

廣告:

使用自定義字符串對頁的各個版本進行緩存:

protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now.AddMinutes(1.0));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);
Response.Cache.SetVaryByCustom("minorversion");
}


protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now.AddMinutes(1.0));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);
Response.Cache.VaryByHeaders["Accept-Language"] = true;
}


<%@ outputcache duration="60" varybyparam="none" varybyheader="accept-language" %>

VaryByHeader-- 更據HTTP頭信息改變緩存區內容(不支持用戶控件輸出緩存)


<%@ OutputCache Duration="#ofseconds"
Location="Any | Client | Downstream | Server | None |
ServerAndClient "
Shared="True | False"
VaryByControl="controlname"
VaryByCustom="browser | customstring"
VaryByHeader="headers"
VaryByParam="parametername"
CacheProfile="cache profile name | ''"
NoStore="true | false"
SqlDependency="database/table name pair | CommandNotification"
%>


VaryByCustom
表示自定義輸出緩存要求的任意文本。如果賦予該屬性的值為 browser,緩存將隨瀏覽器名稱和主要版本信息的不同而異。如果輸入自定義字符串,則必須在應用程序的 Global.asax 文件中重寫 GetVaryByCustomString 方法。


VaryByControl
一個分號分隔的字符串列表,用于更改用戶控件的輸出緩存。這些字符串代表用戶控件中聲明的 ASP.NET 服務器控件的 ID 屬性值


VaryByCustom="UserID"自定義

第一個:
public override string GetVaryByCustomString(HttpContext context, String arg) {

string cacheKey = "";

switch(arg) {

case "CategoryPageKey":

if (Request.IsAuthenticated == true) {

cacheKey = "QQQ" + context.Request.QueryString["category_id"] + context.Request.QueryString["requestedPage"];

}

else {

cacheKey = "AAA" + context.Request.QueryString["category_id"] + context.Request.QueryString["requestedPage"];

}

break;

case "UserID" :

if (Request.IsAuthenticated == true) {

cacheKey = "UserID_In";

}

else {

cacheKey = "UserID_Out";

}

break;

}

return cacheKey;

}

第二個:

global.asax 文件中:
<script>
public override string GetVaryByCustomString(HttpContext context, string arg){
If (arg = "minorversion "){
Return "Version= " + context.Request.Browser.MinorVersion.ToString();
}
}
</script>


第三個:
<%@ Application Language="C#" %>

<script runat="server">

public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (arg.ToLower() == "prefs ")
{
HttpCookie cookie = context.Request.Cookies["Language"];
if (cookie != null)
{
return cookie.Value;
}
}
return base.GetVaryByCustomString(context, arg);
}

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup

}

</script>

廣告:

相關文章
使用自定義字符串對頁的各個版本進行緩存GetVaryByCustomString
cms新聞系統購買咨詢
掃描關注 廣州閱速軟件科技有限公司
掃描關注 廣州閱速科技
主站蜘蛛池模板: 常宁市| 泰顺县| 唐海县| 杂多县| 宜宾县| 周至县| 泌阳县| 临城县| 平昌县| 青浦区| 广南县| 射洪县| 抚宁县| 凤城市| 治多县| 台湾省| 无为县| 汉寿县| 碌曲县| 桐城市| 宁南县| 古蔺县| 阿克| 蒙阴县| 禄丰县| 定兴县| 陈巴尔虎旗| 建平县| 云霄县| 兴宁市| 贡嘎县| 伊吾县| 崇文区| 栖霞市| 阳泉市| 伊金霍洛旗| 台江县| 德州市| 平陆县| 无极县| 乐业县|