Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

asp.netµÄÔÚÏßÈËÊýͳ¼Æ

Ò»°ãÊÇ·ÅÔÚGlobal.asaxÖУ¬´úÂëÈçÏ£º
<%@ Application Language="C#" %>
<mce:script runat="server"><!--
void Application_Start(object sender, EventArgs e)
{
// ÔÚÓ¦ÓóÌÐòÆô¶¯Ê±ÔËÐеĴúÂë
//Application["online"] = 10;//ÉèÖÃĬÈÏÔÚÏßÈËÊý,ÔÚÐéÄâ¿Õ¼äÉÏ£¬ÕâÀï²»»áÖ´ÐÐ
}

void Application_End(object sender, EventArgs e)
{
// ÔÚÓ¦ÓóÌÐò¹Ø±ÕʱÔËÐеĴúÂë
}

void Application_Error(object sender, EventArgs e)
{
// ÔÚ³öÏÖδ´¦ÀíµÄ´íÎóʱÔËÐеĴúÂë
}
void Session_Start(object sender, EventArgs e)
{
// ÔÚлỰÆô¶¯Ê±ÔËÐеĴúÂë
Application.Lock();
if (Application["online"] == null)//ÔÚÐéÄâ¿Õ¼äÉÏ£¬Application_Start²»»áÖ´ÐÐ
Application["online"] = 10;
int online = (int)Application["online"];
online++;
Application["online"] = online;
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
// ÔڻỰ½áÊøʱÔËÐеĴúÂë¡£
// ×¢Òâ: Ö»ÓÐÔÚ Web.config ÎļþÖÐµÄ sessionstate ģʽÉèÖÃΪ
// InProc ʱ£¬²Å»áÒý·¢ Session_End ʼþ¡£Èç¹û»á»°Ä£Ê½ÉèÖÃΪ StateServer
// »ò SQLServer£¬Ôò²»»áÒý·¢¸Ãʼþ¡£
Application.Lock();
int online = (int)Application["online"];
online--;
Application["online"] = online;
Application.UnLock();
}

// --></mce:script>
ǰ̨ÕâÑùµ÷ÓÃ
µ±Ç° <%=Application["online"] %> ÈËÔÚÏß
×¢£º
1¡¢
  application.lock  
       ...   
  application.unlock  
   
  Ö®¼äµÄ´úÂëÔÚÒ»¸öʱ¿ÌÖ»Äܹ©Ò»¸ö·ÃÎÊÕßʹÓÃ.   
    
  Ò²¾ÍÊÇ˵£¬µ±Ò»¸öÓû§ÔÚÖ´ÐÐÉÏÃæÁ½ÕßÖ®¼äµÄ´úÂëʱ,ÆäËûµÄÓû§ÊDz»¿ÉÒÔ·ÃÎÊÕâ¶Î´úÂëµÄ¡£
2¡¢
Application_StartÖ»ÓÐÔÚÍøÕ¾·¢²¼Ö®ºó£¬µÚÒ»µÇ½µ½¸ÃÍøÕ¾µÄÈË£¬²Å»áÖ´ÐÐËü¡£¶øSession_Start£¬Ôò²»¹ÜÊDz»ÊǵÚÒ»¸öÈ˵ǽµ½¸ÃÍ


Ïà¹ØÎĵµ£º

Ò»¸ö¼òµ¥µÄASP.NET +ACCESS µÇ¼

Ê×Ò³£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head ......

ASP.NETµÄACCESSÊý¾Ý¿â²Ù×÷Àà

//private string datapatch = ConfigurationSettings.AppSettings["acessconn"];//Êý¾Ý¿âµØÖ· 
private string datapatch = "db/global.asa";//Êý¾Ý¿âµØÖ· 
/// 
/// È¡µÃdataset 
// 
/// ²éѯÓï¾ä 
/// 
public DataSet GetDataSet(string Commandtext) 
{&nbs ......

asp.netÔÚÏßÈËÊýͳ¼Æ

ÓÐÈËÒ²ÎÊÁ˸öÔÚÏßͳ¼ÆµÄÎÊÌ⣬ÎҵļûÒâÊÇÕâÑùµÄ£º  
  ÔÚApplication_StartʼþÖмÓÈëÒÔÏ´úÂ룺  
  Application.Lock();  
  Application.["UserCount"]=0;  
  Application.Unlock();  
   
  Session_Startʼ ......

asp.netÑéÖ¤¿Ø¼þ²»Æð×÷ÓõĽâ¾ö°ì·¨

×î½üд³ÌÐòÒ»Ö±³öÎÊÌ⣬ÒÔÇ°Ò»¸öÕ¾Èý¼¸Ìì¾ÍÇáËɸ㶨£¬ÏÖÔÚÒ»¸öÄ£¿é¾­³£¸ã°ëÌ죬NND
ÏÂÎ翪·¢¿áÒ×»¯×±Æ·É̳Ç(http://www.koyee.net)Ò»¸ö±íµ¥Ìá½»¹¦ÄÜÄ£¿é£¬±¾µØÈκÎÎÊÌⶼûÓÐÁË£¬´«µ½·þÎñÆ÷Éϱ¾ÒÔΪûÊÂÁË£¬ºóÀ´Ò»¼ì²éËùÓеÄÑéÖ¤¿Ø¼þ¶¼²»Æð×÷ÓÃÁË£¬Ö±½Ó¶¼Ìá½»¹ýÈ¥ÁË£¬ÓôÃÆ£¬Ô­ÒÔΪ³ÌÐò±»¸Ä´íÁË£¬¼ì²é±¾µØ»¹ÊÇûÈκÎÎÊÌ⣬¼ ......

»¶Ó­Äúѧϰ asp.net 2.0

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
< ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ