???? HOW TO: ???????? ??? ????? ???????? ?? ??? ?????? ??????? ?????? ?? ASP.NET ???????? Visual C# .NET

?????? ????????? ?????? ?????????
???? ???????: 308147 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ????? ??????? ?????? ???????? ???????? ?????? ????? ??? ????? ?? ????? Microsoft ASP.NET. ?????? ????? ?? ??? ??????? ?????? ?? ????? ???? DataSet ?? ????? ??????? ?????? ?? ????? ????? ??? ???? ??? ????? ????? ??????? ?????? ?????? ?????? ??? ??????? ????? ??. ?????? ??? ????? ?? ?????? ????? ??????? ?????? ?? ????? ?? ?????? ???????? ??? ???? ???? ??? "???????" ?? ??? ???????.

???????

  • Microsoft Windows 2000 ?? Microsoft Windows XP
  • ???? ??????? ???????? ?? Microsoft "(IIS)
  • ???? ??? Microsoft .NET
  • Microsoft SQL Server

????? ????? ??? ASP.NET

?????? Microsoft Visual C# .NET ????? ???? ??? Microsoft ASP.NET ?????? DataCacher ???????:
  1. ???? Microsoft Visual Studio .NET.
  2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
  3. ?? ???? ?????? ????? ???? ? ???? ??? Visual C# ?????? ??? ????? Project ?? ???? ??? ????? ??? ASP.NET ??? ?????.
  4. ?? ?????? ??????? ???? DataCacher ??? ?? ??? ??????? ?? ???? ??????? WebApplication# ????? ????????? ?? ???? URL. ??? ??? ?????? ?????? ??????, ???? ??? ??? ?????? ?? http://localhost ????? ?????? ??? http://localhost/DataCacher.

????? ????? ???

??????: ?????? ????? ?? ???????? ?? ?????? "????? ???" ????????? ???????? ??????? ?? ??? ??????.

????? ?????? ????? ??????? ?????? ?????:
  1. ????? "????? ???" ???? ???? DataCacheSample.aspx ??? ??????? ?? Visual Studio .NET:
    1. ???? ??? ?????? ?????? ??? ???? ????? ?? ???? Explorer.
    2. ???? ??? ????? ?? ???? ??? ????? WebForm ????.
    3. ??? DataCacheSample.aspx ????? ???.
    4. ???? ??? ???.
  2. ??? ????? ??????? ????? ????? ????? "???????" ??? "?? IDE .NET Studio Visual (???? ??????? ?????????) ? ????? ??" ????? ??? "??? ??????:
    1. ??????? ????? ????? ???????? ???? ?? "????? ???" ??? ??????.
    2. ???? ??? ???? ??????. ????? ????? ?????? ??? CreateNewOrCached ?? ?? ?????? ??????? Text ??? ????? ???? ?? ??????.
  3. ????? ?? "????? ???" ????:
    1. ?????? ???? ????? ????? ???????? ???? "????? ???" ??? ??? ?????? ?? ???? ???????.
    2. ???? ??? ???? ??????. ????? ????? ?????? ??? ????? ?? ?? ?????? ??????? Text?????.
  4. ????? ????? "????? ???":
    1. ??????? ????? ????? ???????? ???? ????? "????? ???" ??? ?????? ?? ???? ???????.
    2. ???? ??? ????? ?????. ????? ????? ?????? ??? CacheStatus ?? ?? ?????? ????? ??????? Text.
  5. ??????? ????? ????? ???????? ???? ???? ???? "????? ???" DataGrid ??? ?????? ?? ???? ???????. ???? ??????? ???? ????? ??????? ????????? DataGrid1 ?? ????? ????? ???? ?????? ???.

????? ????????? ????????

????? ????????? ???????? ?????? ??????? ????? ??????? ?????? ?????? ??????? ????? ??????? ?????? ? ?????? ????? ????? ??????? ???????:
  1. ???? ??? ?????? ?????? ??? ???? .aspx ??? ?? ???? ??? ??? ????????? ???????? ??? ??? ???? ??????? ????????? ????????.
  2. ?????? ??? ??? ?????? ???? ?? ????? System.Data.SqlClientSystem.Data ? ?????? ??????? System.Web.Caching ??? ????? ????? ????? ????? ?? ???? ????????? ???????? ???????. ??? ??? ?????? Visual Studio. ????? NET ?????? "????? ???" ????? ?? ????? ????? ??? ?? ????????? ???????? - ??? ?????? ?????? ??? ???:
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.Web.Caching;
    						
    ??????: ????? ?????? ??????? ??? ????? ????? ??? ???? ?? ??? ??? ????? ??????? ?????? ?? ????? ??? ???????.
  3. ??? ????? ??????? ????? ????? "?????" ? ???? ????? ??????? ??? ???? CreateNewOrCached ???? ????? CreateNewOrCached_Click ?? ???? ????????? ???????? ???????.
  4. ?? ?????? ????????? ???????? ??????? ??? ????? CreateNewOrCached_Click:
    private void CreateNewOrCached_Click(object sender, System.EventArgs e) {
    	//Attempt to create a DataSet object from the cache entry with the key "CacheDataSetEmployees" 
    	object CacheDataSetEmployees = (DataSet)Cache.Get("CacheDataSetEmployees");
    	
            //Check to see if the object is null
    	if(CacheDataSetEmployees == null)
    	{
    	     //Set a value for the cache entry that will serve as the 
    	     //key for the dependency to be created on
    	     Cache["SqlPubsEmployees"] = "SomeValue";
    
    	     //Create the array of cache key item names
    	     string[] keys = new String[1];
    	     keys[0] = "SqlPubsEmployees";
    				
    	     DataSet ds = new DataSet();
    	     //Create the connection and pass in the ConnectionString
    	    SqlConnection MySqlConn = new SqlConnection("Server=kronicas17;Trusted_Connection=Yes;initial catalog=pubs");
    	     //Create the Data Adapter and pass in the command text and connection to use
    	     SqlDataAdapter MySda = new SqlDataAdapter("SELECT TOP 10 * FROM Employee", MySqlConn);
    	     //Populate the DataTable "Employees" in the DataSet
    	     MySda.Fill(ds,"Employee");
    	     //Set the DataGrid's DataSource to the "Employee" DataTable
    	     DataGrid1.DataSource = ds.Tables["Employee"];
    				
    	     //Create a dependency object referencing the array of cachekeys (keys)
    	     CacheDependency MyDependency = new CacheDependency(null, keys);
    	     //Insert the DataSet into Cache with a dependency on MyDependency
    	     Cache.Insert("CacheDataSetEmployees", ds, MyDependency);
    				MySqlConn.Close();
    				
    	     //Display the status of the DataSet/Cache Entry
    	     CacheStatus.Text = "New Version Created";
    	}
    	else
    	{
    	     //Display the status of the DataSet/Cache Entry
    	     CacheStatus.Text = "Cached Version Used";
    	     //Set the DataSource to the cached version of the DataSet
    	     DataGrid1.DataSource = CacheDataSetEmployees;
            }
            //Bind the DataGrid to the DataSource
    	DataGrid1.DataBind();
    }
    						
    ??????: ?? ????? ??? ????? ?????_????_??????? ?? ????????? ???????? ?? ??? ?????? ????? ???? ???? ?? ???? SQL. ?????? ??? ????????? ???????? ????? ???? ???? ??? ?? ???? ???? ????? ?????? SQL Server Pubs ?????.
  5. ??? ??????? ????? ????? ????? ?????? DataCacheSample.aspx ???? ????? ??????? ??? ???? "?????" ???? ??? Remove_Click ?? ???? ????????? ???????? ???????.
  6. ?? ?????? ????????? ???????? ??????? ??? ????? Remove_Click:
    private void Remove_Click(object sender, System.EventArgs e)
         {
    	//Remove the cache item listed in the cachekeys array (keys)
    	Cache.Remove("SqlPubsEmployees"); 	//Display the status of the cache item
    	CacheStatus.Text = "Cache Item Removed";
         }
    					
  7. ??? ?????? ?????? ??? ??? Web.config <system.web> ??? </system.web>:
    <identity impersonate=?true? />
    
  8. ?? ??????? ???? ???? ??? ??? ???? ???? "????? ???" ???????? ?????? ?????.
  9. ?? ??????? ???? ?? IDE .NET Studio Visual ???? ??? ????? ?????? ???????.

????? ????????? ????????

  1. ?????? ????????? ???????? ???? ??? ?????? ?????? ??? ?????? DataCacheSample.aspx ?? "?????? ??????" ??? ?? ???? ??? ??? ?? ??????.
  2. ???? ??? ???? CreateNewOrCached ??? ??? ??????? CacheStatus "????? ????? ????" ?? ??? ????? ???? ???? DataGrid.

    ???????:
    • ???? ??????? ????? ????? ???? ??????? CacheStatus ????? ????? ????? ??????? ?????? CacheDataSetEmployees ?????? ??? ?? ??? ??? ???? ????? ??????? ???? ???? ??? ????? ?????. ?? ??? ??????? ??? ????? DataSet ????? ?????? DataGridDataSet ?? ??? ????? DataSet ??? ????? ??????? ?????? ???????? ????? ????? ??????? ?????? "CacheDataSetEmployees".
    • ?? ?????? ??????? ???? ??? ?? ???? ???? ????? ????? ????? ???? CacheDependency ???? ???? MyDependency. ??? ??? ?????? MyDependency ??? ??????? ???? CacheDataSetEmployees ????? ??? ??????? ??? ????? ??????? ?????? ?????? ??????? ??????? ?????. ?? ????? ?????? ??? ????? ???? ??? ??????? ????? ??? ????? ???????? ? ????? ??????? ????? ???? ?? ???????? ??? ????? ??????? ?????? ?????? ??? ??????? ?? ???? ????, ?????.
  3. ???? ??? ???? CreateNewOrCached ??? ????. ???? ????? CacheStatus "??????? ?????? ???????" ? ???? ??? ??? ??? ?? ??????? DataSet ??????? ??????. ????? ?????? ?? ?? ??? ?? ???????? ??????? ?????? ?? ???? ????? ??? ??????? ???????? ?? ????? ?????? Pubs ???????? ???? ??????? SQL ?? ???? ????. ??? ????? ????? ???? ??? ???? CreateNewOrCached ??? ????. ?????? ?? ??? ??? ????????? ???? ???????. ???? ??? ????? ?? ???? ??? CreateNewOrCached ??? ???? ??????? ????????? ???? ?? ??????? ??? ????? ????????.
  4. ???? ??? ???? ?????. ???? ????? CacheStatus "????? ????? ????? ??????? ??????". ???? ????? ??????? ?????? ?????? ????? "SqlPubsEmployees" ?????? ??????? ??????? Cache.Remove ?? ????? Remove_Click. ??? ??? ?????? (????? ????? ??? ??? ?????? ??? ?????? ????? ????? ??????? ??????) ?? MyDependency ??? ?????? ? ??? ????? ?????? "CacheDataSetEmployees" ???? ?????? ???????? ????? ????? ?? ??????? ??? MyDependency ?????? ??????? ?????? ??.
  5. ???? ??? ???? CreateNewOrCached ??? ????. ???? ????? CacheStatus ????? "????? ????? ????" ???? ?? ?????? DataSet based on ?? ??? ?? ??? ?????? ?? ????? ??????? ?????? ??? ????? ?? ?????.
  6. ?? ????? ????? ?? ??? ??? ???? ?????? DataGrid ??? ????????(SSP) ???????? ??? ??? ????? ?????? DataSet ?? ????? ??????? ??????. ???? ??? ????? ??????? EnableViewState ????? ??? True ???? ???????. ???? ????? ???? ???? ?????? ???????? ?? ??? ?? ????? ??? ?????? ????? ????? ??????? ?????? ?? ????????? ????????. ?????? ??? ????? ???? ???? ?? ???? ???? ?????? ?? ?? ????? ? ????? ????? EnableViewState ??? ???.
??????: ?????? ??? ?????? ?? ???? ??????? ?? ?????? ????? ????? ??????? ?????? (???? ???????? ?? ????? ???????? ????????) ???? ?????? ????? ??????? ?????? ????? ???? ?? ??????? ?????? ????? ??????? ?????? ???? ??? ??? ??? ??? ??????? ?? ????? ?? ???? ????? ????? ????? ??????? ?????? (CacheDataSetEmployees ?? ??? ??????) ?????? ???? ?? ?????? ?????? ??? ??????? ?? ????? ??????? ?????? ?????. ??? ?? ?? ????? ??????? ???????? ?????? ???????????; ?????? ??? ???? ?? ????????? ??? ?????? ??????????? ? ???? ??? "???????" ?? ??? ???????.

??????? ??????? ????????

  • ??? ?? ???? ????? ???????? ???? ?? ????? ?? ???? ?????? ????? ??????? ?????? ???????? ?? ??????? ??????? ????? ??????? ??????. ??? ?? ??? ?? ??? ???????? ?????? ???? ??? ??????? ??????? ???? ???? ?? ????? ??????? ??????. ????? ???? ??? ???? ???????? ?? ????? ???????? ???????? ????? ???? ?????? ??? ?? ?? ????? ?????? ??? ??? ????? ????? ??????? ???? ??? ????.
  • ???? ?????? ????? ??????? ?????? ??? ?? ????? ???? ??? ??? ????????? ?? ???? CacheDependency.
  • ??? ??? ?????? ???? ?? ????? ??????? ?????? ?? ??? ???? ????? ?? ?????? ???????? ???? ??? ??????? ?????? ??? ????? ?????? ?? ????? ??????? ??????.

?????

?????? ??? ???? ?? ????????? ??? ??????? CacheItemRemovedCallback ?????, ???? ???? Microsoft ?????? ??? ?????:
????? CacheItemRemovedCallback
http://msdn2.microsoft.com/en-us/library/system.web.caching.cacheitemremovedcallback(vs.71).aspx
??????: ?????? CacheItemRemovedCallback ????? ????? ?? ????? ??????? ????????? ??? ????? ???? ????? ??????? ?????? ?? ????? ??????? ??????.

????? ?? ????????? ??? ??? CacheDependency ???? ???? Microsoft ?????? ??? ?????:
??? CacheDependency
http://msdn2.microsoft.com/en-us/library/system.web.caching.cachedependency(vs.71).aspx
??????: ??? CacheDependency ????? ?????? ????? ??????? ?????? ???? ?? ???? ??????? ?? ??????? ?? ?????? ???????? ?????? ?? ????? ??????? ?????? ??????? ????? ??.

????? ?? ????????? ??? ?????? ??????? ?????? ???????? ???????? ?? ASP.NET ???? ????? Microsoft .NET Framework SDK ???????:
????? ????? ??? ????? ??????? ??????
http://msdn.microsoft.com/en-us/library/cc511535.aspx
?????? ??? ??????? ?????? ??? ?????? ??????? ?????? ???????? ???????? ?? ASP.NET ???? ??? ???? ????????? ????????? ??????? ?? "????? ??????? ?? Microsoft:
305140??????? ASP.NET
307225INFO: ???? ??????? ?????? ASP.NET

???????

???? ???????: 308147 - ????? ??? ??????: 15/?????/1428 - ??????: 2.8
????? ???
  • Microsoft ASP.NET 1.1
  • Microsoft ASP.NET 1.0
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
????? ??????: 
kbmt kbcaching kbdatabase kbhowtomaster KB308147 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????308147

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com