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()
&
Ïà¹ØÎĵµ£º
½çÃæ: Default.aspx
½çÃæÉÏÌí¼ÓµÄ¿Ø¼þ:
Á½¸öTextBox: tEmail(ÓÃÓÚÊäÈëÓû§email),tPassword(ÓÃÓÚÊäÈë×¢²áÃÜÂë)
Ò»¸öButton: bReg
Ò»¸öLabel: lLable(ÓÃÓÚ×¢²á³É¹¦ºóÏÔʾӦ´ð)
DemoµÄ´úÂë: Default.aspx.cs
ÎÒÃÇÏÈ°ÑÊý¾ÝµÄÁ¬½Ó×Ö·û´®Ð´ÔÚWeb.configÀï:
<appSettings>
<add key="oracleconn" value= ......
ÿ´Î½«ÍøÒ³·¢Ë͵½·þÎñÆ÷ʱ£¬¶¼»á´´½¨ÍøÒ³ÀàµÄÒ»¸öÐÂʵÀý¡£ÔÚ´«Í³µÄ Web ±à³ÌÖУ¬Õâͨ³£Òâζ×ÅÔÚÿһ´ÎÍù·µÐгÌÖУ¬Óë¸ÃÒ³¼°¸ÃÒ³ÉϵĿؼþÏà¹ØÁªµÄËùÓÐÐÅÏ¢¶¼»á¶ªÊ§¡£ÀýÈ磬Èç¹ûÓû§½«ÐÅÏ¢ÊäÈëµ½Îı¾¿ò£¬¸ÃÐÅÏ¢½«ÔÚ´Óä¯ÀÀÆ÷»ò¿Í»§¶ËÉ豸µ½·þÎñÆ÷µÄÍù·µÐгÌÖжªÊ§¡£
ΪÁ˽â¾ö´«Í³µÄ Web ±à³Ìµ ......
ÊÓͼ״̬ÊÇ ASP.NET Ò³¿ò¼ÜÓÃÓÚÔÚÍù·µ¹ý³ÌÖ®¼ä±£ÁôÒ³ºÍ¿Ø¼þÖµµÄ·½·¨¡£ÔÚ³ÊÏÖÒ³µÄ HTML ±ê¼Çʱ£¬±ØÐëÔڻط¢¹ý³ÌÖб£ÁôµÄÒ³ºÍÖµµÄµ±Ç°×´Ì¬½«±»ÐòÁл¯Îª Base64 ±àÂë×Ö·û´®¡£È»ºó£¬´ËÐÅÏ¢½«±»·ÅÈëÒ»¸ö»ò¶à¸öÊÓͼ״̬Òþ²Ø×ֶΡ£
1¡¢·½°¸
ÊÓͼ״̬ÓÉ ASP.NET Ò³¿ò¼Ü×Ô¶¯ÓÃÓÚ±£´æÔÚ¸ ......
ASP.NET ÅäÖÃÎļþ¹¦ÄÜÔÊÐíÄú´æ´¢¼òµ¥£¨±êÁ¿£©Öµ¡¢¼¯ºÏºÍÆäËû¸´ÔÓÀàÐÍ£¬ÒÔ¼°Óû§¶¨ÒåµÄÀàÐÍ¡£
1¡¢ÊôÐÔ¶¨ÒåÐÅÏ¢
ÔÚÅäÖÃÎļþÖж¨ÒåÊôÐÔʱ£¬Ó¦Ö¸¶¨½«ÓÃÓÚÒýÓøÃÊôÐÔµÄÃû³Æ¡£ÀýÈ磬Èç¹ûÒª´æ´¢ÓÊÕþ±àÂ룬Ôò¿ÉÒÔ½«ÊôÐÔÃüÃûΪ PostalCode£¬È»ºó¿ÉÒÔ»ñÈ¡ÊôÐÔÖµ²¢½«ÆäÉèÖÃΪ Profile.Pos ......