Asp.net cache-SqlCacheDependency

Source: Internet
Author: User

1. Make the database support SqlCacheDependency
In the. Net Framework 2.0 installation directory (usually WINDOWS \ Microsoft. NET \ Framework \ v2.0.xxxxx), there is an aspnet_regsql.exe. This command line tool can help us make the database support the SqlCacheDependency feature.
Run the "aspnet_regsql-S server name-E-d database name-ed-t traced data table-et" command to enable the corresponding data table to support SqlCacheDependency.
(PS: The parameter can use "aspnet_regsql /?" For query)

 

2. web. config Configuration

<System. web>
<! -Configure the Cache node so that the website supports SqlCacheDependency->
<Caching>
<SqlCacheDependency enabled = "true" pollTime = "1200">
<Databases>
<Add name = "sqlonstringname =" database link string "/>
</Databases>
</SqlCacheDependency>
</Caching>
</System. web>

 

3. Set the outputCache on the page.

<% @ OutputCache Duration = "9999" VaryByParam = "none" SqlDependency = "Northwind: Employees" %>

Northwind is the tracing database, and the following Employees is the data table to be tracked.

 

Basically, data binding is the same as normal. When the records in the data table are modified, the page will be cached again (not immediately. Wait a moment, because you have to wait for the program to cache the page again ^_^ !!)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.