Asp.Net¹¹¼Ü(HttpÇëÇó´¦ÀíÁ÷³Ì) Part.1
Asp.Net¹¹¼Ü(HttpÇëÇó´¦ÀíÁ÷³Ì) - Part.1
ÒýÑÔ
ÎÒ²éÔĹý²»ÉÙAsp.NetµÄÊé¼®£¬·¢ÏÖ´ó¶àÊý×÷Õ߶¼ÊÇÕ¾ÔÚÒ»¸ö±È½Ï¸ßµÄ²ã´ÎÉϽ²½âAsp.Net¡£ËûÃÇÄÍÐÄ¡¢Ï¸ÖµظæËßÄãÈçºÎÒ»²½²½ÍϷſؼþ¡¢ÉèÖÿؼþÊôÐÔ¡¢±àдCodeBehind´úÂ룬ÒÔʵÏÖij¸öÌض¨µÄ¹¦ÄÜ¡£
ÕâÖÖ×ö·¨£¬Êµ¼ÊÉÏÊǻشðÁË“ÈçºÎÈ¥×ö”µÄÎÊÌ⣬ȴûÓлشð“Ϊʲô¿ÉÒÔÕâÑù×ö”µÄÎÊÌâ¡£
¾¡¹ÜÎÒºÜÍƳç Ϥ½»ª ÏÈÉúµÄ¡¶Ê¥µî¼ÀìëµÄAsp.Net¿ª·¢Ïê½â¡·Ò»Ê飬µ«µ±ÎÒ·¿´ÁËÒ»ÏÂÆä¶Ô½ÇÉ«(Role) ºÍ Óû§(Member)µÄ½²½âʱ£¬ÎÒ¾ö¶¨Ìø¹ýÈ¥Ö±½Ó¶ÁºóÃæµÄÕ½ڡ£ÒòΪÎÒ·¢ÏÖËûÒ²ËæÁË´óÁ÷£¬¶ÔÕⲿ·ÖµÄ½²½âÍ£ÁôÔÚ“ÈçºÎÈ¥×ö”µÄ²ãÃæÉÏ¡£ÎÒÏàÐÅÏñϤÏÈÉú ÕâÑùµÄÅ£ÈËÊDz»¿ÉÄܲ»Á˽âµ×²ãÔË×÷ÔÀíµÄ£¬½ö½öÊÇÒòΪÄDZ¾ÊéÔ±¾¾ÍÒѾºÜºñÁË°É¡£
µ±Äã°´“ÈçºÎÈ¥×ö”Ëù½²½âµÄÄÚÈÝÈ¥¿ª·¢³ÌÐòµÄʱºò£¬¶ÔÓÚÄãµÄÓû§£¬ÄãÈÔÊÇÒ»Ãû³ÌÐòÔ±£»µ«¶ÔÓÚʵÏÖÁËMembershipProvider ºÍ RoleProvider ³éÏóÀàµÄ΢Èí¿ª·¢ÈËÔ±À´Ëµ£¬ÄãÒѾ³ÉÁËËûÃǵÄÒ»¸öÓû§¡£
NOTE£ºÎҼȲ»·´¶ÔһЩ×÷ÕßÖ»½²½â“ÈçºÎÈ¥×ö”£¬Ò²²»·´¶ÔÄãֻѧ“ÈçºÎÈ¥×ö”£¬ÕâÑùÒ²ÓÐËüµÄºÃ´¦£¬¾ÍÊÇ¿ÉÒÔ¿ìËÙ¿ª·¢¡£ÎÒÖ»Êǽ¨Òé¶àÕÆÎÕÒ»µãµ×²ã֪ʶ£¬¶ÔһЩÎÊÌâ»áÓиüºÃµÄÀí½â¡£
Ï£Íûͨ¹ýÕâһϵÁÐÎÄÕµĽ²½â£¬¿ÉÒÔÈÃÄã¸üºÃµÄÀí½âAsp.NetµÄÔË×÷ÔÀíºÍ×öÒÔÁ˽⡣
HttpÇëÇó´¦ÀíÁ÷³Ì¸ÅÊö
˼¿¼“ΪʲôÔÚµØÖ·À¸ÊäÈëwww.tracefact.net¾Í¿ÉÒÔ¿´µ½ÕÅ×ÓÑôµÄ¸öÈ˿ռ䣿”£¬ÀàËÆÓÚ˼¿¼“Ϊʲôƻ¹ûÊÇÍùµØÉϵô²»ÊÇÍùÌìÉÏÆ®£¿”¡£¶ÔÓÚÆÕͨ·ÃÎÊÕßÀ´Ëµ£¬Õâ¾ÍÏñÿÌìÌ«Ñô¶«±ßÉýÆðÎ÷±ßÂäÏÂÒ»ÑùÊÇÀíËùµ±È»µÄ£»¶ÔÓںܶà³ÌÐòÔ±À´Ëµ£¬ÈÏΪÕâ¸öÓ뼺Î޹أ¬²»¹ýÊÇϵͳ¹ÜÀíÔ±»òÕßÍø¹ÜÔ±µÄÔðÈΡ£±Ï¾¹£¬IISÊÇ Windows µÄÒ»¸ö×é¼þ£¬ÓÖ²»ÊÇ Asp.Net µÄÒ»¸ö×é³É²¿·Ö¡£¶øʵ¼ÊÉÏ£¬´ÓÄãÇáÅĻسµµ½Ò³Ãæ³ÊÏÖÔÚÄãÑÛÇ°µÄÊ®·ÖÖ®Ò»ÃëÄÚ£¬IISºÍ.Net FrameworkÒѾ×öÁË´óÁ¿µÄÄ»ºó¹¤×÷¡£
Äã¿ÉÄܾõµÃÁ˽âÕâЩĻºó¹¤×÷ÊÇÈçºÎÔË×÷µÄÎ޹ؽôÒª£¬×÷Ϊ³ÌÐòÔ±µÄÄãÖ»Òª±£Ö¤¿ª·¢³öµÄ³ÌÐò¿ÉÒÔ¸ßЧµØÔËÐоͿÉÒÔÁË¡£È»¶ø£¬ÔÚ¿ª·¢¹ý³ÌÖУ¬ÄãÈ´·¢ÏÖ³£³£ÐèҪʹÓÃÖîÈç HttpContext ÕâÑùµÄÀà¡£Õâ¸öʱºò£¬Äã¿ÉÔø˼¿¼¹ýÕâЩÀàµÄ¹¹³ÉºÍÀàµÄʵÌåÊÇÈçºÎ´´½¨µÄ£¿Äã¿ÉÄܼòµ¥µØ»Ø´ð£ºHttpContext´ú±íµ±Ç°ÇëÇóµÄÒ»¸öÉÏÏÂÎÄ»·¾³¡£¿ÉÄãÓÖÖªµÀIIS ¡¢Framework¡¢Asp.Net ÊÇÈçºÎÐͬ¹¤×÷´¦Àíÿ¸öHttpÇëÇó¡¢ÈçºÎÇø·Ö²»Í¬µÄÇëÇó¡¢IIS¡¢Framework¡¢Asp.NetÈýÕßÖ®¼äµÄÊý¾ÝÈçºÎÁ÷¶¯Ã´£¿
»Ø´
Ïà¹ØÎĵµ£º
2.1 ASP.net ÈëÃÅ
¡¡¡¡Í¨³£Ì¸Ò»¸öѧ¿Æ£¬ÎÒÃÇÀÏÊÇ˵£¬ËüÈëÃźܼòµ¥µÄÂASP.netÒ²ÊÇ¡£ASP.netÌá³öÒ»¸ö¸ÅÄ¾ÍÊÇÈÏΪWEBÒ³Ã棬ҲÊÇÒ»¸ö´°Ì壬ËùÒÔ£¬Ñ§Ï°¹ýÃæÏò¶ÔÏó±à³ÌµÄVB VC BC DephiµÄÅóÓÑ£¬Ñ§ÆðÀ´¾Í¼òµ¥¶àÁË¡£
¡¡¡¡Ò»¸öASP.netÒ³ÃæµÄºó׺ÃûÊÇ".aspx"£¬ËùÒÔ£¬IISÔÚÄã°²×°ÍêASP.netʱ£¬Ò²»á°ÑDefault.aspx×÷ΪÄãµÄĬÈÏ ......
Ë®ÏÉ»¨Êý£ºÒ»¸öÈýλÕûÊý¸÷λÊý×ÖµÄÁ¢·½ºÍµÈÓÚ¸ÃÊý±¾Éí¾Í³Æ¸ÃÊýΪˮÏÉ»¨Êý£¬Ë®ÏÉ»¨Êý¹²ÓÐ4¸ö£¬·Ö±ðΪ£º153¡¢370¡¢371¡¢407( ÀýÈ磺1^3 + 5^3 + 3^3 = 153 )¡£ÎÒдµÄ´úÂëÈçÏ£¬ÄãÓÐÆäËûµÄʵÏÖ´úÂëÒ²¿ÉÒÔ·¢±íÆÀÂÛ¡£
int i, m,n,k;
for (i = 100; i < 1000; i++)
{
//È¡µÃ°ÙλÊý
m = i / 100;
//È¡µ ......
ÒòΪ¹«Ë¾µÄ²úÆ·ÓÃasp¿ª·¢£¬ Ç°Ò»¶Îʱ¼äÓÃaspдÁËÒ»¸öÉú³É¾²Ì¬Ò³Ãæ²¢·ÖÒ³µÄ³ÌÐò£¬µ«ÔµÓÚ¶Ô.netµÄÈÈ°®£¬Ð´ÁËÕâ¸ö.netϵÄÉú³É¾²Ì¬Ò³Ãæ²¢·ÖÒ³µÄ³ÌÐò¡£
Ö÷ÒªµÄÔÀí¾ÍÊÇÌ滻ģ°åÀïµÄÌØÊâ×Ö·û¡£
1¡¢¾²Ì¬Ä£°åÒ³Ãæ template.html£¬Ö÷ÒªÊǶ¨ÒåÁËһЩÌØÊâ×Ö·û£¬ÓÃÀ´±»Ìæ»»¡£
<!DOCTYPE HTML PUBLIC "-//W3C//DTD ......
±¾ÎÄĿ¼£º
1.membership¼ò½é
2.membershipÔÚsql serverÖеÄÉèÖÃ
3.ÅäÖÃweb.config
4.´´½¨Óû§CreateUserWizard¿Ø¼þ
5.Óû§µÇ¼login¿Ø¼þ
6.ÏÔʾµ±Ç°Óû§µÄÃû³ÆLoginName¿Ø¼þ
7.¼ì²âÓû§µÄÉí·ÝÑé֤״̬µÄLoginStatus¿Ø¼þ
8.Ϊ²»Í¬Àà±ðÓû§³ÊÏÖ²»Í¬ÄÚÈݵÄLoginView¿Ø¼þ
9.¸ü¸ÄÃÜÂëµÄChangePassword¿Ø¼þ
10.×ÔÖúÕÒ» ......
1¡¢ response.redirect Õâ¸öÌøתҳÃæµÄ·½·¨ÌøתµÄËٶȲ»¿ì£¬ÒòΪËüÒª×ß2¸öÀ´»Ø(2´Îpostback)£¬µ«Ëû¿ÉÒÔÌøתµ½ÈκÎÒ³Ã棬ûÓÐÕ¾µãÒ³ÃæÏÞÖÆ(¼´¿ÉÒÔÓÉÑÅ»¢Ìøµ½ÐÂÀË)£¬Í¬Ê±²»ÄÜÌø¹ýµÇ¼±£»¤¡£µ«ËÙ¶ÈÂýÊÇÆä×î´óȱÏÝ!redirectÌøת»úÖÆ£ºÊ×ÏÈÊÇ·¢ËÍÒ»¸öhttpÇëÇ󵽿ͻ§¶Ë£¬Í¨ÖªÐèÒªÌøתµ½ÐÂÒ³Ã棬Ȼºó¿Í»§¶ËÔÚ·¢ËÍÌøתÇëÇóµ½·þÎñÆ÷¶ ......