ASP.NETÖеÄHttpWorkerRequest¶ÔÏñ¼°ÆäÓ¦ÓÃ
HttpWorkerRequest¶ÔÏñÔÚASP.Net´¦ÀíÁ÷³ÌÖеÄλÖãº
ÿһ¸öASP.NET³ÌÐòÖ´ÐÐʱ¶¼»á¶Ôµ±Ç°URLµÄÇëÇó½øÐнâÎö£¬±¾ÎĽ«·ÖÎöASP.NETÒ³ÃæÇëÇóµÄÔÀí¡£µ±ÎÒÃÇÔÚä¯ÀÀÆ÷ÉÏÊäÈëÒ»¸öURLʱ£¬ Á÷³ÌÈçÏ£º
Ê×Ïȱ»WWW·þÎñÆ÷½Ø»ñ£¨inetinfo.exe½ø³Ì£©£¬ ¸Ã½ø³ÌÊ×ÏÈÅжÏÒ³Ãæºó׺£¬ È»ºó¸ù¾ÝIISÖÐÅäÖþö¶¨µ÷ÓþßÌåµÄÀ©Õ¹³ÌÐò¡£
Èçaspx¾Í»áµ÷ÓÃaspnet_isapi.dll, È»ºóÓÉaspnet_isapi.dll·¢Ë͸øw3wp.exe£¨iis ¹¤×÷Õß½ø³Ì£¬IIS6.0ÖнÐ×ö w3wq.exe£¬IIS5.0ÖнÐ×ö aspnet_wp.exe).
½ÓÏÂÀ´¾ÍÊÇw3wp.exeµ÷ÓÃ.netÀà¿â½øÐоßÌå´¦Àí£¬Á÷³ÌÈçÏ£º
ISAPIRuntime-->HttpRuntime-->HttpApplicationFactory-->HttpApplication-->HttpModule--HttpHandlerFactory-->HttpHandle
1. ISAPIRuntime
Ö÷Òª×÷ÓÃÊǵ÷ÓÃһЩ·ÇÍйܴúÂëÉú³ÉHttpWorkerRequest¶ÔÏó£¬HttpWorkerRequest¶ÔÏó°üº¬µ±Ç°ÇëÇóµÄËùÓÐÐÅÏ¢£¬È»ºó´«µÝ¸øHttpRuntime£¬ÕâÀïÉú³ÉµÄHttpWorkerRequest¶ÔÏó¿ÉÒÔÖ±½ÓÔÚÎÒÃǵÄÒ³ÃæÖе÷Óõģ¬Í¨¹ýËüÈ¡µÃÔʼµÄÇëÇóÐÅÏ¢£º
2. HttpRuntime
a. ¸ù¾ÝHttpWorkerRequest¶ÔÏóÉú³ÉHttpContext£¬HttpContext°üº¬request¡¢responseµÈÊôÐÔ£»
b. µ÷ÓÃHttpApplicationFactoryÀ´Éú³ÉIHttpHandler(ÕâÀïÉú³ÉµÄÊÇÒ»¸öĬÈϵÄHttpApplication¶ÔÏó£¬HttpApplicationÒ²ÊÇIHttpHandler½Ó¿ÚµÄÒ»¸öʵÏÖ)
c. µ÷ÓÃHttpApplication¶ÔÏóÖ´ÐÐÇëÇó
3. HttpApplicationFactory.
Ö÷ÒªÊÇÉú³ÉÒ»¸öHttpApplication¶ÔÏó£º
Ê×ÏÈ»á²é¿´ÊÇ·ñ´æÔÚglobal.asaxÎļþ£¬Èç¹ûÓеĻ°¾ÍÓÃËüÀ´Éú³ÉHttpApplication¶ÔÏ󣬴ÓÕâÀïÎÒÃÇ¿ÉÒÔ¿´µ½global.asaxµÄÎļþÃûÊÇÔÚasp.netµÄ¿ò¼ÜÖÐдËÀµÄ£¬²»ÄÜÐ޸ĵġ£Èç¹ûÕâ¸öÎļþ²»´æÔÚ¾ÍʹÓÃĬÈϵĶÔÏó¡£
4. HttpApplication
Õâ¸öÊDZȽϸ´ÔÓÒ²±È½ÏÖØÒªµÄÒ»¸ö¶ÔÏó, Ê×ÏÈÊÇÖ´Ðгõʼ»¯²Ù×÷£¬±È½ÏÖØÒªµÄÒ»²½¾ÍÊǽøÐÐHttpModuleµÄ³õʼ»¯£º
HttpApplication´ú±í×ųÌÐòÔ±´´½¨µÄWebÓ¦ÓóÌÐò¡£HttpApplication´´½¨Õë¶Ô´ËHttpÇëÇóµÄ HttpContext¶ÔÏó£¬ÕâЩ¶ÔÏó°üº¬Á˹ØÓÚ´ËÇëÇóµÄÖî¶àÆäËû¶ÔÏó£¬Ö÷ÒªÊÇHttpRequest¡¢HttpResponse¡¢ HttpSessionStateµÈ¡£ÕâЩ¶ÔÏóÔÚ³ÌÐòÖпÉÒÔͨ¹ýPageÀà»òÕßContextÀà½øÐзÃÎÊ¡£
Ëü»á¶ÁÈ¡web.configÖÐËùÓÐHttpModuleµÄÅäÖÃ
5. HttpModule
6. HttpHandlerFactory
7. HttpHandler
HttpWorkerRequest µÄÓ¦ÓÃ
1. Using HttpWorkerRequest for getting headers
First, the HttpWorkerRequest class is used internally by ASP.NET, and provides a
Ïà¹ØÎĵµ£º
1¡¢.NetµÄHTTPÇëÇó
.NETÓëASPµÄÔËÐлúÖÆÓкܴó²»Í¬.
ASPµÄÇëÇóÓëÏìÓ¦ÊÇ,ASPÒ³Ãæ±»ÇëÇó,È»ºóÖðÐнâÊÍ.ÊÇ»ùÓÚ¹ý³ÌµÄ.×î¶àÊÇ°üº¬ÁËÎļþ,ÐèÒªÏÈÒýÈëÎļþ°ÕÁË.
¶ø.Net,ÔÚÒ³Ãæ±»ÇëÇóºó,Ê×ÏÈÊǼÓÔØHTTP Module,Õâ²»ÊDZ¾ÎĵÄÖصã.È»ºóÔÙ¼ÓÔØHTTP
Handler.ÕâÒ²²»ÊDZ¾ÎĵÄÖصã.¼ÓÔصÄÕâÁ½Ïî,¶¼ÐèÒªÔÚWebconfigÎļþÖÐÅäÖÃ.´ó¼ÒÖªµÀ ......
private
static
CacheItemRemovedCallback OnCacheRemove
=
null
;
protected
void
Application_Start(
object
sender, EventArgs e)
{
AddTask(
"
DoStuff
"
,
60
);
}
private
vo ......
Cookie (HttpCookieµÄʵÀý)ÌṩÁËÒ»ÖÖÔÚ Web Ó¦ÓóÌÐòÖд洢Óû§Ìض¨ÐÅÏ¢µÄ·½·¨¡£ÀýÈ磬µ±Óû§·ÃÎÊÄúµÄÕ¾µãʱ£¬Äú¿ÉÒÔʹÓÃCookie ´æ´¢Óû§Ê×Ñ¡Ïî»òÆäËûÐÅÏ¢¡£µ±¸ÃÓû§ÔٴηÃÎÊÄúµÄÍøվʱ£¬Ó¦ÓóÌÐò±ã¿ÉÒÔ¼ìË÷ÒÔÇ°´æ´¢µÄÐÅÏ¢¡£
ASP.NETÖеÄcookie£º´´½¨Cookie·½·¨ (1)
Response.Cookies["userName"].Value = “admin" ......
ASP.NETÊÇÒ»¸ö·Ç³£Ç¿´óµÄ¹¹½¨WebÓ¦ÓõÄƽ̨£¬ËüÌṩÁ˼«´óµÄÁé»îÐÔºÍÄÜÁ¦ÒÔÖÂÓÚ¿ÉÒÔÓÃËüÀ´¹¹½¨ËùÓÐÀàÐ͵ÄWebÓ¦Óá£
¾ø´ó¶àÊýµÄÈËÖ»ÊìϤ¸ß²ãµÄ¿ò¼ÜÈ磺 WebForms ºÍ WebServices --ÕâЩ¶¼ÔÚASP.NET²ã´Î½á¹¹ÔÚ×î¸ß²ã¡£
ÕâƪÎÄÕµÄ×ÊÁÏÊÕ¼¯ÕûÀí×Ô¸÷ÖÖ΢Èí¹«¿ªµÄÎĵµ£¬Í¨¹ý±È½Ï IIS5¡¢IIS6¡¢IIS7 ÕâÈý´ú IIS ¶ÔÇëÇóµÄ´¦Àí¹ý³ ......
ʹÓÃASP.Net FormsģʽʵÏÖWebServiceÉí·ÝÑéÖ¤
ÔÚ°²È«ÐÔÒªÇó²»ÊǺܸߵÄASP.Net³ÌÐòÖУ¬»ùÓÚFormsµÄÉí·ÝÑéÖ¤ÊǾ³£Ê¹ÓõÄÒ»ÖÖ·½Ê½£¬¶øÈç¹ûÐèÒª¶ÔWebService½øÐÐÉí·ÝÑéÖ¤£¬×î³£ÓõĿÉÄÜÊÇ»ùÓÚSoap ±êÍ·µÄ×Ô¶¨ÒåÉí·ÝÑéÖ¤·½Ê½¡£Èç¹û¶ÔÁ½Õß×öһϱȽϵĻ°£¬ÏÔÈ»£¬»ùÓÚFormsµÄÑéÖ¤·½Ê½¸ü¼Ó·½±ãÒ×Óã¬ÄÜ·ñ½«F ......