ASP.NET 2.0 ʵÏÖα¾²Ì¬ÍøÒ³·½·¨
¿´ÁËÄÇô¶à£¬»¹ÊÇÇ××Ô¶¯ÊÖʵ¼ùÏÂÓÐЧ¹û¡£
ÒýÓà °Ù¶È ÑîÔÆ·ÉaiÉú»î
ASP.NET 2.0 ʵÏÖα¾²Ì¬ÍøÒ³·½·¨
·½·¨Ò»£ºÀûÓÃHttphandlerʵÏÖURLÖØд£¨Î±URL¼°Î±¾²Ì¬£©
ÎÒÃÇÓÐʱºò»á¼ûµ½ÕâÑùµÄµØÖ·£º“http://www.huoho.com/show-12-34.html”£¬Äã»òÐíÈÏΪÔÚÕ¾µã·þÎñÆ÷¸ùĿ¼“/”Ï´æÔÚÃûΪ“show-12-34.html”µÄÎļþ£¬Æäʵʵ¼ÊËü¿ÉÄÜÊDz»´æÔڵģ¬¶ø¿ÉÄÜÄã¿´µ½µÄÄÚÈÝÊÇ“/aspx/show.aspx?type= 12&id=34”µÄÄÚÈÝ£¬ÎªÊ²Ã´ÒªÕâÑù×öÄØ£¿ÔÒòÓжà¸ö·½Ã棺Ê×ÏÈÊÇÔöÇ¿URLµÄÓѺÃÐÔ£¬¼Ç“show-12-34.html”×Ü±È “/aspx/show.aspx?type=12&id=34”ºÃ¼Ç°É£¿Æä´Î¾ÍÊÇ·½±ãËÑË÷ÒýÇæÊÕ¼£¬ºÜ¶àËÑË÷ÒýÇæ¸ü¿´ºÃ¾²Ì¬HTMLÒ³£¬±ÈÈ磺°Ù¶È£»Æä´Î¾ÍÊdzöÓÚ°²È«ÐԵĿ¼ÂÇ£¬ÒòΪÕâÑùÒþ²ØÁ˲ÎÊý“type”¡¢“id”¡£ÊDz»ÊǺÜÓÐÒâ˼ÄØ£¿
ÆäʵÕâÊÇÀûÓÃURLÖØдʵÏֵģ¬ÏÂÃæÎÒ¾Í˵һÏÂÔÚASP.NET2.0ÏÂÎÒËùÖªµÀµÄ×î¼òµ¥µÄʵÏÖ·½·¨£ºÍ¨¹ýʵÏÖ½Ó¿Ú“IHttpHandler”À´½Ó¹ÜHTTPÇëÇó£¬Follow me!
1.ÔÚ×ÊÔ´¹ÜÀí·½°¸ÖÐÌí¼ÓÒ»¸öÀ࣬ÀàµÄ´úÂëÈçÏ£º
//ÀàURLRewriter³ÌÐòÇåµ¥£º
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// UrlRewriter URLÖØдÀà
/// Author:yoyo
/// blog:http://yangmingsheng.cn
/// </summary>
public class UrlRewriter : IHttpHandler //ʵÏÖ“IHttpHandler”½Ó¿Ú
{
public UrlRewriter()
&
Ïà¹ØÎĵµ£º
½ñÌìÎÒÖ÷ҪѧϰÁËUpdateModeÊôÐÔ¼°Ê¹ÓÃUpdateTriggers£¬°ÑÊéÖÐËù½ÌÊÚµÄÄÚÈÝÓöà¸öÀý×Óʵ¼ùÁËһϣ¬È·ÊµÃ÷°×ÁËÐí¶à¡£
UpdateMode
Ê×ÏÈÔÚÉÏһƪҲÌáµ½¹ýÕâÑùÒ»¸öÀíÂÛ£ºÔÚ̸ÂÛUpdatePanel¿Ø¼þµÄË¢ÐÂʱ£¬µ±UpdatePanel¿Ø¼þÖеÄ×ӿؼþ´¥·¢Async-Postback¶¯×÷ʱ£¬Ë¢ÐµÄÇøÓòÊ ......
ÈçºÎ¸øAsp.Net ÍøÕ¾ÏîÄ¿´ò°ü
1¡¢´ò¿ªÄãµÄÏîÄ¿£¬ÔÚ<½â¾ö·½°¸¹ÜÀíÆ÷>ÖÐÓÃÊó±êÓÒ»÷ÄãµÄ<½â¾ö·½°¸>£¬Ñ¡Ôñ<Ìí¼Ó>-<н¨ÏîÄ¿>¡£
2¡¢<Ìí¼ÓÐÂÏîÄ¿>¶Ô»°¿òÖÐÑ¡Ôñ<°²×°ºÍ²¿ÊðÏîÄ¿>-<web°²×°ÏîÄ¿>¡££¨×¢Ò⣺<web°²×°ÏîÄ¿>µÄ´æ·Å·¾¶¡££©
3¡¢vs.net µÄ´°¿Ú×ó²à»áÏÔʾ<Îļþ ......
»ñÈ¡Óйط¢³öÒ³ÇëÇóµÄÓû§µÄÐÅÏ¢¡£
Ò»¡¢HttpContext Àà
·â×°Óйظö±ð HTTP ÇëÇóµÄËùÓÐ HTTP Ìض¨µÄÐÅÏ¢¡£
HttpContext ÀàÐ͹«¿ªÒÔϳÉÔ±¡£
¹¹Ô캯Êý
Ãû³Æ
˵Ã÷
HttpContext
ÒÑÖØÔØ¡£ ³õʼ»¯ LinePragmaCodeInfo ÀàµÄÒ»¸öÐÂʵÀý¡£
·½·¨
Ãû³Æ
˵Ã÷
AddError
½«Òì³£Ìí¼Óµ½µ±Ç° HTTP ÇëÇóµÄÒ ......
ASP.NET ÅäÖÃÎļþ¹¦ÄÜÔÊÐíÄú´æ´¢¼òµ¥£¨±êÁ¿£©Öµ¡¢¼¯ºÏºÍÆäËû¸´ÔÓÀàÐÍ£¬ÒÔ¼°Óû§¶¨ÒåµÄÀàÐÍ¡£
1¡¢ÊôÐÔ¶¨ÒåÐÅÏ¢
ÔÚÅäÖÃÎļþÖж¨ÒåÊôÐÔʱ£¬Ó¦Ö¸¶¨½«ÓÃÓÚÒýÓøÃÊôÐÔµÄÃû³Æ¡£ÀýÈ磬Èç¹ûÒª´æ´¢ÓÊÕþ±àÂ룬Ôò¿ÉÒÔ½«ÊôÐÔÃüÃûΪ PostalCode£¬È»ºó¿ÉÒÔ»ñÈ¡ÊôÐÔÖµ²¢½«ÆäÉèÖÃΪ Profile.Pos ......
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕʱÊÕ»ØÁ¬½ ......