asp.net»º´æµÄһЩ»ù±¾ÖªÊ¶
½éÉÜ
»º´æÊÇÔÚÄÚ´æ´æ´¢Êý¾ÝµÄÒ»Ïî¼¼Êõ£¬Ò²ÊÇASP.NETÖÐÌṩµÄÖØÒªÌØÐÔÖ®Ò»¡£ÀýÈçÄã¿ÉÒÔÔÚ¸´ÔÓ²éѯµÄʱºò»º´æÊý¾Ý£¬ÕâÑùºóÀ´µÄÇëÇó¾Í²»ÐèÒª´ÓÊý¾Ý¿âÖÐÈ¡Êý¾Ý£¬¶øÊÇÖ±½Ó´Ó»º´æÖлñÈ¡¡£Í¨¹ýʹÓûº´æ¿ÉÒÔÌá¸ßÓ¦ÓóÌÐòµÄÐÔÄÜ¡£
Ö÷ÒªÓÐÁ½ÖÖÀàÐ͵Ļº´æ£º
1.Êä³ö»º´æOutput caching
2.Êý¾Ý»º´æData caching
1. Êä³ö»º´æ(Output Caching)
ʹÓÃÊä³ö»º´æ£¬Äã¿ÉÒÔ»º´æ×îºóÊä³öµÄHTMLÒ³Ã棬µ±ÏàͬµÄÒ³ÃæÔÙ´ÎÇëÇóµÄʱºò£¬ASP.NET²»»áÔÙÖ´ÐÐÒ³ÃæµÄÉúÃüÖÜÆÚºÍÏà¹Ø´úÂë¶øÊÇÖ±½ÓʹÓûº´æµÄÒ³Ã棬Óï·¨ÈçÏ£º
<%@ OutputCache Duration=”60” VaryByParam=”None” %>
Duration ÊôÐÔÉèÖÃÒ³Ã潫±»»º´æ60Ãî¡£ÈκεÄÓû§ÇëÇ󶼻ᱻ»º´æ£¬ÔÚ»º³åµÄ60ÃëÄÚÏàͬµÄÇëÇ󶼻áÖ±½ÓʹÓûº´æµÄÒ³Ãæ¡£µ±»º´æ¹ýÆÚºóASP.NET»áÔÙ´ÎÖ´ÐÐÒ³Ãæ´úÂë²¢ÇÒΪÏÂÒ»¸ö60Ãë´´½¨Ò»¸öеÄHTML»º´æ¡£
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="OutputCachingTest.aspx.cs" Inherits="OutputCachingTest" Title="Untitled Page" %> <%@ OutputCache Duration="20" VaryByParam="None" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <div class="title">Output Cache</div> Date: <asp:Label ID="lblDate" runat="server" Text="" /> Time: <asp:Label ID="lblTime" runat="server" Text="" /> </asp:Content> protected void Page_Load(object sender, EventArgs e) { lblDate.Text = DateTime.Now.ToShortDateString(); lblTime.Text = DateTime.Now.ToLongTimeString(); }
ÔÚÕâ¸öÀý×ÓÖÐÒ³Ã潫±»»º´æ20Ãë¡£
ͨ¹ý²éѯ×Ö·û´®»º´æ(Cache by Query String )
ÔÚÊ
Ïà¹ØÎĵµ£º
aspÖÐSessionµÄ¹¤×÷ÔÀí£º
aspµÄSessionÊǾßÓнø³ÌÒÀÀµÐԵġ£ASP Session״̬´æÓÚIISµÄ½ø³ÌÖУ¬Ò²¾ÍÊÇinetinfo.exeÕâ¸ö³ÌÐò¡£ËùÒÔµ±inetinfo.exe½ø³Ì±ÀÀ£Ê±£¬ÕâЩÐÅÏ¢Ò²¾Í¶ªÊ§¡£ÁíÍ⣬ÖØÆð»òÕ߹رÕIIS·þÎñ¶¼»áÔì³ÉÐÅÏ¢µÄ¶ªÊ§¡£
asp.net SessionµÄʵÏÖ
asp.netµÄSessionÊÇ»ùÓÚHttpModule¼¼Êõ×öµÄ£¬HttpModule¿ÉÒÔÔÚÇëÇó±» ......
test.xml
<?xml version="1.0" encoding="utf-8" ?>
<root>
<R SecuCode="601600" Glossary="ѧITÍø²âÊÔ»ñÈ¡XML½á¹ûÏÔʾÕý³££¬¡£¡£¡£¡£¡£¡£¡£¹þ¹þ" />
<R SecuCode="600056" Glossary="²âÊÔµÚ¶þ¸ö£¬¡£¡£¡£¡£¡£¡£¡£¹þ¹þ" />
</root>
ÏÂÃæxml½âÎö ......
ÒÔϾÑé×ܽá×Ô£¬²¢ÇÒ¾¹ýÑéÖ¤
1£¬²»²ÎÓëPOSTBACK»úÖƵĿؼþ£¬²»ÒªÓ÷þÎñÆ÷¿Ø¼þ£¬¾¡Á¿Óþ²Ì¬HTML±ê¼Ç
2£¬±àÒëʱʹÓÃRELEASEÅäÖÃ
3£¬ÕýʽͶÈëÓ¦ÓÃʱ£¬¼Ç׎«DEBUGÉèΪFALSE
4£¬SMARTNAVIGATE¼Ç×ÅÉèΪTRUE£¬Ëü¿ÉÒÔÈÃä¯ÀÀÕ߸оõµ½ÄãÐÔÄܵÄÌá¸ß
5£¬Èç¹û²»ÊDZØÐë±£³Ö¸üеÄÒ³Ã棬Çë¼Çס¼ÓÈëÉùÃ÷£¬Ëü¿ÉÒÔ´ó·ùÌá¸ßÐÔÄÜ
6£¬³ý ......
½ñÌ죬ѧϰÁËASP.NETÖÐÁ¬½ÓÊý¾Ý¿âµÄ¸÷ÖÖ·½·¨£¬ÕâÊÇÎÒ×Ô¼ºµÄÒ»¸öС×ܽᣬ²»Ò»¶¨ÍêÈ«ÕýÈ·£¬½ö¹©²Î¿¼£¡ O(∩_∩)O~
Á¬½ÓSQLÊý¾Ý¿âµÄ·½·¨£º
(Ò»)¡¢ÔÚWeb.ConfigÖд´½¨Á¬½Ó×Ö·û´®£º
1¡¢
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename= ......
µÚÒ»£¬ н¨ÍøÕ¾£¬Ñ¡ÔñÀàÐÍΪasp.net web ·þÎñ¡£
ϵͳ×Ô¶¯ÎªÄ㽨Á¢Á˸öÎļþservice.asmx.Õâ¾ÍÊÇÒ»¸ö×î¼òµ¥µÄweb service·þÎñ¡£Äã¿ÉÒÔÖ±½ÓÔËÐв鿴Ч¹û¡£
µÚ¶þ£¬ÎÒÃÇÐèÒªµÄÊÇÐÞ¸Äservice.csÖеĴúÂ룬À´Âú×ãÎÒÃǵÄÒªÇó¡£
Ð޸ĺóµÄService.csÖеĴúÂëΪ£º
using System;
using System.Web;
using System.Web.Services;
......