ѧϰASP.NETÖеÄApplication¡¢Session¡¢Cookie
ѧϰASP.NETÖеÄApplication¡¢Session¡¢Cookie
1.Application½¨Á¢µÄ±äÁ¿£¬ÔÚϵͳÄÚ²¿Èκεط½¶¼¿ÉÒÔ·ÃÎÊ£¬Í¨³£ÍøÕ¾µØ·ÃÎÊͳ¼Æ¿ÉÄÜ»áÓõĽ϶ࡣÈç¹ûÒªÓõ½ApplicationÊ×ÏÈÔÚVS2005Öн¨Á¢Ò»¸öglobal.asaÎļþ¡£ÀýÈçÎÒÃÇҪдһ¸öÍøÕ¾·ÃÎÊÊýÁ¿µÄͳ¼ÆµÄ»°£¬ÔÚglobal.asaÖÐÏÈÉùÃ÷±äÁ¿iCount¡£ÈçÏÂËùʾ£º
protected void Application_Start(object sender, EventArgs e)
{
Application["iCount"] = 0;
}
È»ºóÔÚPage_LoadʼþÖдòÈëÒÔÏ´úÂ룺
protected void Page_Load(object sender, EventArgs e)
{
Application["iCount"] = (int)Application["iCount"] + 1;
Response.Write(Application["iCount"]);
}
ÔËÐкó¾Í¿ÉÒÔ¿´µ½¼ÆÊý£¬Ã¿Ë¢ÐÂÒ»´Î¼ÆÊý»á×Ô¶¯ÀÛ¼Ó¡£Èç¹ûҪֹͣÀۼӵĻ°£¬Ö»ÄÜ°ÑIISÍ£Ö¹ºóÔÙÆô¶¯£¬´Ëʱ¼ÆÊý»á×Ô¶¯¹éÁã
ÓÉÓÚApplication±äÁ¿ÊÇÒ»¸ö¹²ÏíµÄ¶ÔÏó£¬ËùÒÔÓжàÈËÀ´·ÃÎÊËüµÄʱºòÎÒÃǾͱØÐëÓõ½Ëø¶¨¡£µ±Ä³Ò»¸öÓû§ÐèÒª²Ù×÷ËüµÄʱºò¾ÍÓÃlockËø¶¨Ëü£¬²Ù×÷Íê³ÉºóÓÃunlockÀ´½âËø¡£´úÂëÈçÏ£º
protected void Page_Load(object sender, EventArgs e)
{
Application.Lock;
Application["iCount"] = (int)Application["iCount"] + 1;
Application.UnLock;
Response.Write(Application["iCount"]);
}
2. SessionÊÇÿ¸öÓû§Ê¹ÓóÌÐòʱ¾Í»á½¨Á¢¶ÔÏó£¬Ò²¾ÍÊÇApplication¶ÔÏóÖ»ÓÐÒ»¸ö£¬¶øSession¶ÔÏóÓкܶà¸ö¡£Session²
Ïà¹ØÎĵµ£º
ÕûÊý»òÕßСÊý£º^[0-9]+\.{0,1}[0-9]{0,2}$
Ö»ÄÜÊäÈëÊý×Ö£º"^[0-9]*$"¡£
Ö»ÄÜÊäÈënλµÄÊý×Ö£º"^\d{n}$"¡£
Ö»ÄÜÊäÈëÖÁÉÙnλµÄÊý×Ö£º"^\d{n,}$"¡£
Ö»ÄÜÊäÈëm~nλµÄÊý×Ö£º¡£"^\d{m,n}$"
Ö»ÄÜÊäÈëÁãºÍ·ÇÁ㿪ͷµÄÊý×Ö£º"^(0|[1-9][0-9]*)$"¡£
Ö»ÄÜÊäÈëÓÐÁ½Î»Ð¡ÊýµÄÕýʵÊý£º"^[0-9]+(.[0-9]{2})?$"¡£
Ö»ÄÜÊäÈëÓÐ1~3λСÊýµÄ ......
Ê×Ïȼòµ¥½éÉÜһϠWCF ÊÇʲô£¬È»ºóÔÙ¶Ô WCF ºÍ Asp.net Web service ×ö¸ö±È½Ï¡£
Windows Communication Foundation (WCF) ÊÇÓÃÓÚ¹¹½¨ÃæÏò·þÎñµÄÓ¦ÓóÌÐòµÄ¿ò¼Ü¡£½èÖú WCF£¬¿ÉÒÔ½«Êý¾Ý×÷ΪÒì²½ÏûÏ¢´ÓÒ»¸ö·þÎñÖÕ½áµã·¢ËÍÖÁÁíÒ»¸ö·þÎñÖÕ½áµã¡£·þÎñÖÕ½áµã¿ÉÒÔÊÇÓÉ IIS ³ÐÔصijÖÐø¿ÉÓõķþÎñµÄÒ»²¿·Ö£¬Ò²¿É ......
1.Asp.NetÖм¸ÖÖÏàËƵıê¼Ç·ûºÅ: < %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Container.DataItem("tit") %>
< %= %>: ÔÚ³ÌÐòÖ´ÐÐʱ±»µ÷Ó㬿ÉÒÔÏÔʾºǫ́±äÁ¿Öµ
Èç:
*.aspxÖУº < %= a ......
ÔÚGlobal.asaxÆô¶¯Ò»ÌõÏ߳̾ÍokÁË£¬ÏÂÃæÊÇÆô¶¯Ï̶߳¨Ê±Ð´ÎļþµÄÀý×Ó
ÔÚGlobal.asax
C# code:
<%@ Application Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Threading" %>
<script runat="server">
string LogPath;  ......