26ÖÖÌá¸ß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
Ïà¹ØÎĵµ£º
using System.Text.RegularExpressions;
/// <summary>
/// Ò³ÃæÊý¾ÝУÑéÀà
/// ÀîÌìƽ
/// 2004.8
/// </summary>
public class PageValidate
{ ......
Session¼´»á»°£¬ÊÇÖ¸Ò»¸öÓû§ÔÚÒ»¶Îʱ¼äÄÚ¶Ôijһ¸öÕ¾µãµÄÒ»´Î·ÃÎÊ¡£
Session¶ÔÏóÔÚ.NETÖжÔÓ¦HttpSessionStateÀ࣬±íʾ“»á»°×´Ì¬”£¬¿ÉÒÔ±£´æÓ뵱ǰÓû§»á»°Ïà¹ØµÄÐÅÏ¢¡£
Session¶ÔÏóÓÃÓÚ´æ´¢´ÓÒ»¸öÓû§¿ªÊ¼·ÃÎÊij¸öÌض¨µÄaspxµÄÒ³ÃæÆ𣬵½Óû§À뿪Ϊֹ£¬Ìض¨µÄÓû§»á»°ËùÐèÒªµÄÐÅÏ¢¡£Óû§ÔÚÓ¦ÓóÌÐòµ ......
1.//µ¯³ö¶Ô»°¿ò.µã»÷תÏòÖ¸¶¨Ò³Ãæ
Response.Write(" <script>window.alert('¸Ã»áԱûÓÐÌá½»ÉêÇë,ÇëÖØÐÂÌá½»£¡')
</script>");
Response.Write(" <script>window.location
='http://www.51aspx.com/bizpulic/upmeb.aspx' </script>");
2.//µ¯³ö¶Ô»°¿ò
Response.Write(" <script lang ......
µÚÒ»£º
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } µÚ¶þ£º
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script language=javascript>window.location.href=document.URL; < /script&g ......