ASP.NETÊ®¸öÓÐЧÐÔÄÜÓÅ»¯µÄ·½·¨
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕʱÊÕ»ØÁ¬½Ó£¬µÈ´ýÏÂÒ»´ÎµÄÁ¬½ÓÇëÇó¡£Á¬½Ó³ØµÄ´óСÊÇÓÐÏ޵ģ¬Èç¹ûÔÚÁ¬½Ó³Ø´ïµ½×î´óÏ޶ȺóÈÔÒªÇó´´½¨Á¬½Ó£¬±ØÈ»´ó´óÓ°ÏìÐÔÄÜ¡£Òò´Ë£¬ÔÚ½¨Á¢Êý¾Ý¿âÁ¬½ÓºóÖ»ÓÐÔÚÕæÕýÐèÒª²Ù×÷ʱ²Å´ò¿ªÁ¬½Ó£¬Ê¹ÓÃÍê±ÏºóÂíÉϹرգ¬´Ó¶ø¾¡Á¿¼õÉÙÊý¾Ý¿âÁ¬½Ó´ò¿ªµÄʱ¼ä£¬±ÜÃâ³öÏÖ³¬³öÁ¬½ÓÏÞÖƵÄÇé¿ö¡£
ʹÓô洢¹ý³Ì
´æ´¢¹ý³ÌÊÇ´æ´¢ÔÚ·þÎñÆ÷ÉϵÄÒ»×éÔ¤±àÒëµÄSQLÓï¾ä£¬ÀàËÆÓÚDOSϵͳÖеÄÅú´¦ÀíÎļþ¡£´æ´¢¹ý³Ì¾ßÓжÔÊý¾Ý¿âÁ¢¼´·ÃÎʵŦÄÜ£¬ÐÅÏ¢´¦Àí¼«ÎªÑ¸ËÙ¡£Ê¹Óô洢¹ý³Ì¿ÉÒÔ±ÜÃâ¶ÔÃüÁîµÄ¶à´Î±àÒ룬ÔÚÖ´ÐÐÒ»´ÎºóÆäÖ´Ðй滮¾ÍפÁôÔÚ¸ßËÙ»º´æÖУ¬ÒÔºóÐèҪʱֻÐèÖ±½Óµ÷Óûº´æÖеĶþ½øÖÆ´úÂë¼´¿É¡£ÁíÍ⣬´æ´¢¹ý³ÌÔÚ·þÎñÆ÷¶ËÔËÐУ¬¶ÀÁ¢ÓÚASP.NET³ÌÐò£¬±ãÓÚÐ޸ģ¬×îÖØÒªµÄÊÇËü¿ÉÒÔ¼õÉÙÊý¾Ý¿â²Ù×÷Óï¾äÔÚÍøÂçÖеĴ«Êä¡£
ÓÅ»¯²éѯÓï¾ä
ASP.NETÖÐADOÁ¬½ÓÏûºÄµÄ×ÊÔ´Ï൱´ó£¬SQLÓï¾äÔËÐеÄʱ¼äÔ½³¤£¬Õ¼ÓÃϵͳ×ÊÔ´µÄʱ¼äÒ²Ô½³¤¡£Òò´Ë£¬¾¡Á¿Ê¹ÓÃÓÅ»¯¹ýµÄSQLÓï¾äÒÔ¼õÉÙÖ´ÐÐʱ¼ä¡£±ÈÈ磬²»ÔÚ²éѯÓï¾äÖаüº¬×Ó²éѯÓï¾ä£¬³ä·ÖÀûÓÃË÷ÒýµÈ¡£
2. ×Ö·û´®²Ù×÷ÐÔÄÜÓÅ»¯
ʹÓÃÖµÀàÐ͵ÄToString·½·¨
ÔÚÁ¬½Ó×Ö·û´®Ê±£¬¾³£Ê¹ÓÃ"+"ºÅÖ±½Ó½«Êý×ÖÌí¼Óµ½×Ö·û´®ÖС£ÕâÖÖ·½·¨ËäÈ»¼òµ¥£¬Ò²¿ÉÒԵõ½ÕýÈ·½á¹û£¬µ«ÊÇÓÉÓÚÉæ¼°µ½²»Í¬µÄÊý¾ÝÀàÐÍ£¬Êý×ÖÐèҪͨ¹ý×°Ïä²Ù×÷ת»¯ÎªÒýÓÃÀàÐͲſÉÒÔÌí¼Óµ½×Ö·û´®ÖС£µ«ÊÇ×°Ïä²Ù×÷¶ÔÐÔÄÜÓ°Ïì½Ï´ó£¬ÒòΪÔÚ½øÐÐÕâÀà´¦Àíʱ£¬½«ÔÚÍйܶÑÖзÖÅäÒ»¸öеĶÔÏó£¬ÔÓеÄÖµ¸´ÖƵ½Ð´´½¨µÄ¶ÔÏóÖС£Ê¹ÓÃÖµÀàÐ͵ÄToString·½·¨¿ÉÒÔ±ÜÃâ×°Ïä²Ù×÷£¬´Ó¶øÌá¸ßÓ¦ÓóÌÐòÐÔÄÜ¡£
ÔËÓÃStringBuilderÀà
StringÀà¶ÔÏóÊDz»¿É¸Ä±äµÄ£¬¶ÔÓÚString¶ÔÏóµÄÖØи³ÖµÔÚ±¾ÖÊÉÏÊÇÖØд´½¨ÁËÒ»¸öString¶ÔÏó²¢½«ÐÂÖµ¸³Óè¸Ã¶ÔÏó£¬Æä·½·¨ToString¶ÔÐÔÄܵÄÌá¸ß²¢·ÇºÜÏÔÖø¡£ÔÚ´¦Àí×Ö·û´®Ê±£¬×îºÃʹÓÃStringBuilderÀ࣬Æä.NET ÃüÃû¿Õ¼äÊÇSystem.Text¡£¸ÃÀಢ·Ç´´½¨ÐµĶÔÏ󣬶øÊÇͨ¹ýAppend£¬Remove£¬InsertµÈ·½·¨Ö±½Ó¶Ô×Ö·û´®½øÐвÙ×÷£¬Í¨¹ýToString·½·¨·µ»Ø²Ù×÷½á¹û¡£
Æ䶨Òå¼°²Ù×÷Óï¾äÈçÏÂËùʾ£º
int num;
System.Text.StringBuilder str = new System.Text.StringBuilder(); //´´½¨×Ö·û´®
str.Appen
Ïà¹ØÎĵµ£º
µÚÒ»²½£º
½«Ä³¸öÒ³ÃæµÄ·½·¨ ÓÐ webmethod attribute;
[WebMethod]
//Ö»ÄÜÊÇ public static µÄ·½·¨
public static DateTime GetCurrentTime()
{
return DateTime.UtcNow;
}
µÚ¶þ²½£º
Ò³ÃæÓÐÒ»¸öScriptManager ÉèÖÃËüµÄenablepagemethod=true;
asp:ScriptManager ID="Scri ......
Ò»¡¢Cookie ¸ÅÊö
1¡¢·½°¸
Cookie ÌṩÁËÒ»ÖÖÔÚ Web Ó¦ÓóÌÐòÖд洢Óû§Ìض¨ÐÅÏ¢µÄ·½·¨¡£ÀýÈ磬µ±Óû§·ÃÎÊÄúµÄÕ¾µãʱ£¬Äú¿ÉÒÔʹÓà Cookie ´æ´¢Óû§Ê×Ñ¡Ïî»òÆäËûÐÅÏ¢¡£µ±¸ÃÓû§ÔٴηÃÎÊÄúµÄÍøվʱ£¬Ó¦ÓóÌÐò±ã¿ÉÒÔ¼ìË÷ÒÔÇ°´æ´¢µÄÐÅÏ¢¡£
2¡¢±³¾°
Cookie ÊÇһС¶ÎÎı¾ÐÅÏ¢£ ......
ͨ³£²¿ÊôÍøÕ¾µÄʱºòÐèÒª±àÒëÄÇЩÐèÒªµÄÎļþ£¬ºÍһЩϵͳÐèÒªµÄ×é¼þ¡£
»á¸Ð¾õµ½ºÜ·±Ëö¡£
·¢²¼ÍøÕ¾ÊÇÒ»¸ö²»´íµÄÑ¡Ôñ:Ö±½Ó·¢²¼·þÎñÆ÷ÉÏ£¬ÉèÖúÃÕ¾µãÓë¶Ë¿Ú¼´¿É¡£ÒÔÏÂÊÇ×ܽáµÄ²½Öè¡£¡£¡£
µÚÒ»¡¢Êǽ«ÍøÕ¾ÀïËùÓеÄÊý¾ÝÁ¬½Ó¶¼×ö³É´Óweb.configÖжÁÈ¡£¬ÕâÑùµÄ»°£¬¾Í¿ÉÒÔÒ»ÀÍÓÀÒÝÁË¡£
µÚ¶þ¡¢¾ÍÊÇIISÉèÖÃÁË£¬ÔÚIISÖеÄasp.netÖÐ ......
״̬¹ÜÀíÊÇÄú¶Ôͬһҳ»ò²»Í¬Ò³µÄ¶à¸öÇëÇóά»¤×´Ì¬ºÍÒ³ÐÅÏ¢µÄ¹ý³Ì¡£ÓëËùÓлùÓÚ HTTP µÄ¼¼ÊõÒ»Ñù£¬Web ´°ÌåÒ³ÊÇÎÞ״̬µÄ£¬ÕâÒâζ×ÅËüÃDz»×Ô¶¯Ö¸Ê¾ÐòÁÐÖеÄÇëÇóÊÇ·ñÈ«²¿À´×ÔÏàͬµÄ¿Í»§¶Ë£¬»òÕßµ¥¸öä¯ÀÀÆ÷ʵÀýÊÇ·ñÒ»Ö±Ôڲ鿴ҳ»òÕ¾µã¡£´ËÍ⣬µ½·þÎñÆ÷µÄÿһÍù·µ¹ý³Ì¶¼½«Ïú»Ù²¢ÖØд´½¨Ò³£»Òò´ ......
ASP.NET ÅäÖÃÎļþ¹¦ÄÜÓë ASP.NET ³ÉÔ±×ʸñ¡¢ASP.NET ½ÇÉ«¹ÜÀíÒÔ¼°ÆäËû ASP.NET ¹¦ÄÜʹÓÃͬһ»ùÓÚÌṩ³ÌÐòµÄ½á¹¹¡£ASP.NET ÅäÖÃÎļþ¹¦ÄÜÊÇÒ»¸ö·Ö²ãϵͳ£¬ÆäÖÐÅäÖÃÎļþ¹¦ÄܵŦÄÜ£¨ÌṩÀàÐÍ»¯ÊôÐÔÖµ²¢¹ÜÀíÓû§±êʶ£©Óë»ù´¡Êý¾Ý´æ´¢Çø·ÖÀë¡£ÅäÖÃÎļþ¹¦ÄÜÒÀÀµÓÚÅäÖÃÎļþÌṩ³ÌÐò£¨Êý¾ÝÌṩ³ÌÐò£©À´Ö´Ðд洢ºÍ¼ìË÷ÅäÖÃÎļþÊôÐÔ ......