Asp.Net ¹¹¼Ü(Http Handler ½éÉÜ) Part.2
Asp.Net ¹¹¼Ü(Http Handler ½éÉÜ) - Part.2
ÒýÑÔ
ÔÚ Part.1 HttpÇëÇó´¦ÀíÁ÷³Ì Ò»ÎÄÖУ¬ÎÒÃÇÁ˽âÁËHttpÇëÇóµÄ´¦Àí¹ý³ÌÒÔ¼°ÆäËüһЩÔË×÷ÔÀí¡£ÎÒÃÇÖªµÀHttp¹ÜµÀÖÐÓÐÁ½¸ö¿ÉÓýӿڣ¬Ò»¸öÊÇIHttpHandler£¬Ò»¸öÊÇIHttpModule£¬µ«ÔÚPart.1ÖУ¬ÎÒ²¢Ã»ÓÐÏêϸ½²ÊöÈçºÎ¶ÔËüÃǽøÐбà³Ì£¬Ö»ÊÇÇáÃèµÐ´µØÒ»±Ê´ø¹ý¡£ËùνѧÒÔÖÂÓã¬Ç°ÃæÒѾ½éÉÜÁ˲»ÉÙ¸ÅÄîºÍÔÀí¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃÇͨ¹ý¼¸¸ö·¶ÀýÀ´Á˽â IHttpHandler£¬¿´¿´ÕÆÎÕÕâЩÔÀíµÄʵ¼ÊÓÃ;¡£
IHttpHandler ¸ÅÊö
¿ÉÄܺÍÎÒÒ»Ñù£¬ºÜ¶àAsp.Net¿ª·¢ÈËÔ±¶¼ÓйýAspµÄ±³¾°£¬ÒÔÖÁÓÚÎÒÃÇÔÚ¿ª·¢³ÌÐòµÄʱºò£¬Í¨³£¶¼ÊÇÔÚ“Ò³Ã漶”ÉÏ˼¿¼£¬Ò²¾ÍÊÇ˵ÎÒÃÇÏÖÔÚÕýÔÚ×öµÄÕâ¸öÒ³ÃæÓ¦¸ÃÓÐʲôÑùµÄ¹¦ÄÜ£¬ÊǽøÐÐÒ»¸öÎʾíµ÷²é»¹ÊÇÒ»¸öÊý¾Ý¿â²éѯµÈµÈ¡£¶øºÜÉÙÔÚ“ÇëÇ󼶔˼¿¼£¬¿¼ÂÇÓÐûÓа취À´Í¨¹ý±àÂëµÄ·½Ê½À´²Ù¿ØÒ»¸öHttpÇëÇó¡£
ʵ¼ÊÉÏ£¬FrameworkÌṩÁËһϵÁеĽӿںÍÀ࣬ÔÊÐíÄã¶ÔÓÚHttpÇëÇó½øÐбà³Ì£¬¶øʵÏÖÕâÒ»²Ù×÷µÄÒ»¸öÖ÷ÒªµÄ½Ó¿Ú£¬¾ÍÊÇ IHttpHandler(ÁíÒ»¸öÊÇIHttpModule)¡£
Ó¦¸Ã»¹¼ÇµÃµÚÒ»½ÚÖÐÎÒÃÇÌáµ½¹ý ISAPI£¬Ëü¸ù¾ÝÎļþÃûºó׺°Ñ²»Í¬µÄÇëÇóת½»¸ø²»Í¬µÄ´¦Àí³ÌÐò¡£µ«ÊÇ×Ðϸ¿´¿´¾Í»á·¢ÏÖ£º¼¸ºõÒ»´ó°ëµÄÎļþ¶¼½»¸ø aspnet_isapi.dll È¥´¦ÀíÁË¡£ºÜÃ÷ÏÔ£¬aspnet_isapi.dll ²»¿ÉÄܶÔÿÖÖÎļþ²ÉÓÃͬһÖÖ·½Ê½´¦Àí£¬ÄÇô aspnet_isapi.dll ÊÇÈçºÎ¸ü½øÒ»²½´¦Àí²»Í¬µÄÎļþ£¬½»ÓÉËÈ¥´¦ÀíÄØ£¿ÎªÁ˸ãÇå³þÕâ¸öÎÊÌ⣬ÎÒÃÇÐèÒª´ò¿ª»úÆ÷ÉÏC:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\ Ŀ¼ÏµÄweb.config Îļþ¡£
NOTE£ºÎÒ²éÔÄÁ˺ܶà×ÊÁÏ£¬¶¼ËµÊÇÔÚ machine.config ÖУ¬µ«Êµ¼ÊÉÏ v2.0.50727 ϵÄmachine.configÖÐhttpHandlers½áµãÊÇÕâÑùµÄ£º<httpHandlers />£¬²¢Ã»Óиø³öÏêϸµÄ´¦Àí³ÌÐò£¬ÔÚWeb.configÖвÅÄÜ¿´µ½¡£¶øv1.1.4322 ϵÄmachine.configÖÐÈ´ÓС£
ÕÒµ½httpHandlers½áµã£¬Ó¦¸Ã¿ÉÒÔ¿´µ½ÈçÏÂÕâÑùµÄ´úÂë(×öÁËÊ¡ÂÔ)£º
<httpHandlers>
... ... //ÂÔ
<add path="*.axd" verb="*" type="System.Web.HttpNotFoundHandler" validate="True" /><add path="*.aspx" verb="*" type="System.Web.UI.PageHandlerFactory" validate="True" />
<add path="*.ashx" verb="*" type="System.Web.UI.SimpleHandlerFactory" validate="True" />
<add path="*.asax" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />
<add
Ïà¹ØÎĵµ£º
PHPÓëASP.NET±È½ÏµÄ¸÷¸ö·½ÃæÊÇʲôÄØ£¿PHPÓëASP.NET±È½ÏµÄ±ØÒªÐÔÊÇʲôÄØ£¿ÄÇô±¾Îľ͸øÄãÒ»¸ö´ð°¸¡£
PHPÓëASP.NET±È½ÏµÄÇ°ÑÔ£¬²»¹ÜÄãÊDz»ÊÇÒѾѡÔñÁËPHP£¬¸ù¾ÝËüÔÚÈçϱí¸ñÖÐÔÚ¼Û¸ñ¡¢Ëٶȡ¢Ð§ÂÊ¡¢°²È«ÐÔ¡¢Æ½Ì¨Ö§³ÖÐԺͿªÔ´Óë·ñÉϵıíÏÖ£¬ÎÒÃǶ¼ÄÜÅжϳöËüµÄÇ¿ÏîÊÇԶʤÓÚÈõµãµÄ¡£Î¨Ò»²»×ãµÄÊÇȱÉÙÃæÏò¶ÔÏóµÄÖ§ ......
ËÑË÷ÒýÇæÓÅ»¯¶ÔÈκÎÃæÏò¹«ÖÚµÄÍøÕ¾À´Ëµ¶¼·Ç³£ÖØÒª£¬ASP.net 4.0 Ϊ´Ë¾Í×öÁË´óÁ¿¸ÄÔì¡£ÕâЩ¸Ä½ø°üÀ¨ÈçÏ£º 301ÓÀ¾ÃÐÔÖض¨Ïò Ëæ×Åʱ¼äµÄǨÒÆ£¬ÍøÕ¾µÄһЩҳÃæµØÖ·»á·¢Éú±ä»¯£¬Õâ»áµ¼ÖÂËÑË÷ÒýÇæÊÕ¼µÄÁ´½ÓµØÖ·¡¢Óû§ÊղصĵØַʧЧ¡£Response.Redirect() ¾ÍÊǽâ¾öÕâ¸öÎÊÌâµÄ¡£µ«ÊÇResponse.Redirect ÓÐÒÔÏÂÎÊÌ⣺ Response. ......
ʹÓÃWebClient×Ô¶¯Ìîд²¢Ìá½»ASP.NETÒ³Ãæ±íµ¥
ÔÚ.NETÖÐͨ¹ý³ÌÐòÌîдºÍÌá½»±íµ¥»¹ÊDZȽϼòµ¥¡£±ÈÈ磬ҪÌá½»Ò»¸öÈçÏÂͼËùʾµÄµÇ¼±íµ¥£º
ÌîдºÍÌá½»ÒÔÉÏ±íµ¥µÄ´úÂëÈçÏ£º
&nb ......
Êý¾Ý°ó¶¨ÒÔ¼°Container.DataItemµÄ¾ßÌå·ÖÎö
Áé»îµÄÔËÓÃÊý¾Ý°ó¶¨²Ù×÷
°ó¶¨µ½¼òµ¥ÊôÐÔ:<%#UserName%>
°ó¶¨µ½¼¯ºÏ:<asp:ListBox id="ListBox1" datasource='<%# myArray%>' runat="server">
°ó¶¨µ½±í´ïʽ:<%#(class1.property1.ToString() + "," + class1.property2.ToString())%>
°ó¶¨µ½·½·¨·µ» ......