ASP.NET 2.0 ÖеÄSqlCacheDependencyÌØÐÔ
Ëü»¹»áÔÚÖ¸¶¨µÄÊý¾Ý¿âÖÐÔö¼Ó¼¸¸ö´æ´¢¹ý³Ì£¬ÓÃÀ´ÈÃASP.NETÒýÇæ²éѯ׷×ÙµÄÊý¾Ý±íµÄÇé¿ö¡£
È»ºó£¬Ëü»á¸øÎÒÃÇҪ׷×ÙµÄTable¼ÓÉϼ¸¸öTrigger£¬·Ö±ð¶ÔÓ¦µ½Insert¡¢Update¡¢Delete²Ù×÷£¬Õ⼸¸öTriggerµÄÓï¾ä·Ç³£¼òµ¥£¬¾ÍÊÇ°Ñ“AspNet_SqlCacheTablesForChangeNotification”±íÖжÔÓ¦“tableName”×Ö¶ÎΪÕâ¸ö×·×ٵıíµÄÃû³ÆµÄ¼Ç¼µÄ“changeId”×ֶμÓÉÏÒ»¸ö1¡£
ASP.NETÒýÇæͨ¹ýÖ´ÐÐËü¼ÓÉϵĴ洢¹ý³Ì“AspNet_SqlCachePollingStoredProcedure”£¬Õâ¸ö´æ´¢¹ý³ÌÖ±½Ó·µ»Ø“AspNet_SqlCacheTablesForChangeNotification”±íµÄÄÚÈÝ£¬ÈÃASP.NETÒýÇæÖªµÀÄĸö±íµÄÊý¾Ý·¢ÉúµÄ±ä»¯¡£Ä¬ÈÏÿ500ºÁÃëÖ´ÐÐÕâ¸ö´æ´¢¹ý³ÌÒ»´Î£¬²»¹ý¿ÉÒÔÔÚweb.configÀïÃæÐÞ¸ÄÕâ¸ö¼ä¸ôʱ¼ä£¬ÎҵľÑéÊÇÕâ¸ö²éѯ²Ù×÷Ò²ÊǺܺÄ×ÊÔ´µÄ£¬ºÇºÇ¡£
2¡¢ web.configÅäÖÃ
ÔÚweb.configÀïÃæµÄÅäÖÃÔÙ¼òµ¥²»¹ýÁË
<configuration>
<!-- ¼ÓÉϺÏÊʵÄÊý¾Ý¿âÁ¬½Ó×Ö·û´® -->
<connectionStrings>
<add name="SqlServerConnectionString"
connectionString="server=sqlserver1;uid=sa;pwd=
password;database=PortalDB " />
</connectionStrings>
<system.web>
<!-- ÅäÖÃCacheÒ»¶Î£¬Ê¹Ö®Ö§³ÖSqlCacheDependency -->
<cache>
<sqlCacheDependency enabled="true" pollTime="500">
<databases>
<add name=" PortalDB "
connectionStringName=" SqlServerConnectionString " />
Ïà¹ØÎĵµ£º
µÚÒ»ÖÖÊÇÔÚapsxÒ³ÃæÉÏ·ÅÒ»¸öLable¿Ø¼þ
ÕâÖÖ·½Ê½¿ÉÒÔдJavascriptµÈ¿ØÖÆÒ³Ã棬ºÍ²¼¾ÖÒ³Ãæ
ÈçÏ£ºHTMLÒ³Ãæ´úÂ룺
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>¶àýÌå²¥·ÅÒ³Ãæ</TITLE>
<meta content=" ......
///<summary>
///<author>·ÉÓ¥@ASPCool.com</author>
///<description>±¾ÎÄÓÃasp.netʵÏÖ°Ñ´ËÎÄÍƼö¸øºÃÓѵŦÄÜ¡£</desciption>
///<copyright>ASP¿á¼¼Êõ×ÊѶÍø(www.ASPCool.com)</copyright>
///</summary ......
¹ØÓÚASP.NETƽ̨ϵÄWeb FormsºÍMVC£¬Õ§Ò»¿´À´£¬´óÓÐÒ»ÖÖ“¼ÈÉú褺ÎÉúÁÁ”µÄ¸Ð¾õ£¬µ«×øÏÂÀ´×Ðϸ˼¿¼£¬»¹ÊÇÓÐÆä¸÷×Ô´æÔڵĵÀÀíµÄ¡£Ê×ÏÈ,ÎÒÃÇÏÈÀ´¿´Ò»ÏÂWeb Forms, ¼¸ÄêµÄʵ¼ùÖ¤Ã÷Web FormsÊÇÒ»¸ö·Ç³£Îȶ¨ºÍ³ÉÊìµÄƽ̨£¬ÎÞÒÉËüÊÇÇ¿´óµÄ£¬µ«Ò²²»ÊÇÍêÃÀÎÞȱµÄ¡£´ÓÒÔϼ¸¸ö·½ÃæÀ´¿´ËüµÄÇ¿´óÖ®´¦£º
1¡¢ÐÔÄÜÓÅÐ ......
ÔÚASP.NET 2.0ÖУ¬ÓÐʱºòÐèÒª¶ÔASP.NETÉú³ÉµÄHTML´úÂë½øÐд¦Àí£¬»òÕßÊDZ£´æ³É¾²Ì¬Îļþ¡£ASP.NET Ìá
¹©ÁËÖ±½Ó½«ÇëÇó±£´æ³ÉÎļþµÄ·½·¨£ºHttpRequest.SaveAs·½·¨¡£ÏÂÃæÕâ¸ö·½·¨¾ÍÊÇÔÚASP.NET 2.0Öеõ½
ASP.NETÉú³ÉµÄHTML´úÂ룬ͬʱ£¬Éú³ÉÒ»¸ö¾²Ì¬ÎļþµÄ·½·¨¡£
C#
<%@ Page Language="C#" AutoEventWireup="true" %&g ......