Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ASP.NETÖÐÖ´ÐÐURLÖØд

 
¿ÉÒÔʹÓà ISAPI ɸѡÆ÷ÔÚ IIS Web ·þÎñÆ÷¼¶±ðʵÏÖ URL ÖØд£¬Ò²¿ÉÒÔʹÓà HTTP Ä£¿é»ò HTTP ´¦Àí³ÌÐòÔÚ
ASP.NET ¼¶±ðʵÏÖ URL ÖØд¡£±¾ÎÄÖصã½éÉÜÈçºÎʹÓà ASP.NET ʵÏÖ URL ÖØд£¬Òò´ËÎÒÃǽ«²»¶ÔʹÓà ISAPI ɸѡÆ÷ʵÏÖ
URL ÖØдµÄϸ½Ú½øÐÐÉîÈë̽ÌÖ¡£µ«ÊÇ£¬ÓдóÁ¿µÄµÚÈý·½ ISAPI ɸѡÆ÷¿ÉÓÃÓÚ URL ÖØд£¬ÀýÈ磺
ISAPI
Rewrite

IIS Rewrite

PageXChanger

»¹ÓÐÐí¶àÆäËûµÄɸѡÆ÷£¡
ͨ¹ý System.Web.HttpContext
ÀàµÄ RewritePath()
·½·¨£¬¿ÉÒÔÔÚ ASP.NET ¼¶±ðʵÏÖ URL ÖØд¡£HttpContext

Àà°üº¬ÓйØÌض¨ HTTP ÇëÇóµÄ HTTP Ìض¨ÐÅÏ¢¡£¶ÔÓÚ ASP.NET ÒýÇæÊÕµ½µÄÿ¸öÇëÇ󣬾ùΪ¸ÃÇëÇó´´½¨Ò»¸ö HttpContext
ʵÀý¡£´ËÀà¾ßÓÐÈçÏÂÊôÐÔ£ºRequest
ºÍ Response
£¬Ìṩ¶Ô´«ÈëÇëÇóºÍ´«³öÏìÓ¦µÄ·ÃÎÊ£»Application
ºÍ Session
£¬Ìṩ¶ÔÓ¦ÓóÌÐòºÍ»á»°±äÁ¿µÄ·ÃÎÊ£»User
£¬ÌṩÓйØͨ¹ýÁËÉí·ÝÑéÖ¤µÄÓû§µÄÐÅÏ¢£»ÆäËûÏà¹ØÊôÐÔ¡£
ʹÓà RewritePath()

·½·¨¿ÉÒÔ½ÓÊܵ¥¸ö×Ö·û´®×÷ΪҪʹÓõÄз¾¶¡£HttpContext
ÀàµÄ RewritePath(string)

·½·¨ÔÚÄÚ²¿¶Ô Request
¶ÔÏóµÄ Path
ÊôÐÔºÍ QueryString
ÊôÐÔ½øÐиüС£³ýÁË RewritePath(string)
£¬.NET
Framework 1.1 »¹°üÀ¨ÁíÒ»ÖÖÐÎʽµÄ RewritePath()
·½·¨£¬´Ë·½·¨¿ÉÒÔ½ÓÊÜÈý¸ö×Ö·û´®ÊäÈë²ÎÊý¡£´Ë±¸ÓÃÖØÔØÐÎ
ʽ²»½öÒªÉèÖà Request
¶ÔÏóµÄ Path
ÊôÐÔºÍ QueryString

ÊôÐÔ£¬»¹ÒªÉèÖÃÄÚ²¿³ÉÔ±±äÁ¿£¬ÕâЩ±äÁ¿ÓÃÓÚ¼ÆËã Request
¶ÔÏóµÄ PhysicalPath
¡¢PathInfo
ºÍ FilePath
ÊôÐÔÖµ¡£
ÒªÔÚ ASP.NET ÖÐʵÏÖ URL ÖØд£¬ÐèÒª´´½¨ HTTP Ä£¿é»ò HTTP
´¦Àí³ÌÐò£¬ÒÔ±ãÍê³ÉÒÔϲÙ×÷£º
¼ì²é±»ÇëÇóµÄ·¾¶£¬ÒÔÈ·¶¨ URL ÊÇ·ñÐèÒªÖØд¡£
Èç¹ûÐèÒªÖØд£¬Í¨¹ýµ÷Óà RewritePath()
·½·¨À´ÖØд·¾¶¡£
ÀýÈ磬¼ÙÉèÎÒ
ÃǵÄÍøÕ¾Öаüº¬Ã¿¸öÔ±¹¤Í¨¹ý /info/employee.aspx?empID=employeeID ¾ù¿É·ÃÎʵÄÐÅÏ¢¡£ÎªÁËʹ URL
¿ÉÒÔ¸ü¶àµØ±»“ɾ½Ú”£¬ÎÒÃÇ¿ÉÒÔ¾ö¶¨Í¨¹ýÒÔϵØÖ·À´·ÃÎÊÔ±¹¤Ò³Ã棺/people/EmployeeName.aspx¡£Õâ¾ÍÊÇÎÒÃÇҪʹÓà URL
ÖØдµÄÒ»¸öÀý×Ó¡£Ò²¾ÍÊÇ˵£¬ÔÚÇëÇó /people/ScottMitchell.aspx Ò³Ãæʱ£¬ÎÒÃÇÒªÖØд¸Ã URL£¬ÒÔ±ãʹÓÃ
/info/employee.aspx?empID=1001 Ò³Ãæ¡£
ʹÓà HTTP Ä£¿éÖ´ÐÐ URL ÖØд
ÔÚ
ASP.NET ¼¶±ðÖ´ÐÐ URL ÖØдʱ£¬¿ÉÒÔʹÓà HTTP Ä£¿é»ò HTTP ´¦Àí³ÌÐòÀ´Ö´ÐÐÖØд¡£Ê¹Óà HTTP
Ä£¿éʱ£¬±ØÐë¾ö¶¨ÔÚÇëÇóÓÐЧÆ


Ïà¹ØÎĵµ£º

ASP.NetÒ³Ã澲̬»¯

 ²½Ö裺
£±.¡¡Ð½¨Ò»¸öWEB½â¾ö·½°¸Ãû³ÆΪHtmlStatic¡£
£².¡¡ÔÚÏîĿϽ¨Ò»¸öHtmlTemp.htmÆä´úÂëÈçÏ£º
¡¡¡¡¡¡<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head&g ......

ASP.NETÖÐCookieµÄÓ÷¨

CookieΪ¿Í»§¶ËÐÅÏ¢´æ·Å¶ÔÏ󣬿ÉÒÔ°ÑÓû§µÄÐÅÏ¢±£´æÔÚÓû§±¾µØ£¬²»±Ø×ÜÊÇ·ÃÎÊ·þÎñÆ÷
ÓëSession²»Í¬£¬SessionΪÓû§È«¾Ö±äÁ¿£¬¶ÔÓÚ¸ÃÓû§µÄËùÓвÙ×÷¹ý³Ì¶¼ÓÐЧ¡£
//1¡£´´½¨Cookie¶ÔÏó
 HttpCookie newCookie = new HttpCookie("User");
//2¡£CookieÖÐÌí¼ÓÐÅÏ¢ÏΪ¼üÖµ¶Ô£¬key/value
newCookie.Values.Add("Name" ......

ASP.NETÒ³ÃæÄ£ÐÍ

Ò»¡¢ASP.NETÒ³Ãæ
Ò»¸öASP.NETÒ³Ã棨»òÕß³ÆΪASP.NET´°Ì壩ÓÉÒÔϼ¸¸ö²¿·Ö×é³É£º
1¡¢Ö¸Áî
£¨°üÀ¨@Page¡¢@Import¡¢@OutputCache¡¢@Implements¡¢@Register¡¢@Master¡¢@Control…£©
2¡¢Head£¨HTMLÎĵµÍ·£©
3¡¢Body£¨HTMLÎĵµÌ壩
´°ÌåÔªËØ£¨form£©
¿Ø¼þ£¨html±ê¼Ç¡¢·þÎñÆ÷¿Ø¼þ±ê¼Ç£©
4¡¢´úÂ루¿Í»§¶Ë´úÂ룬·þÎñ¶Ë ......

ÔÚASP.NETÖÐʹÓÃGlobal.asaxÎļþ

   Global.asax Îļþ£¬ÓÐʱºò½Ð×ö ASP.NET Ó¦ÓóÌÐòÎļþ£¬ÌṩÁËÒ»ÖÖÔÚÒ»¸öÖÐÐÄλÖÃÏìÓ¦Ó¦ÓóÌÐò¼¶»òÄ£¿é¼¶Ê¼þµÄ·½·¨¡£Äã¿ÉÒÔʹÓÃÕâ¸öÎļþʵÏÖÓ¦ÓóÌÐò°²È«ÐÔÒÔ¼°ÆäËüһЩÈÎÎñ¡£ÏÂÃæÈÃÎÒÃÇÏêϸ¿´Ò»ÏÂÈçºÎÔÚÓ¦ÓóÌÐò¿ª·¢¹¤×÷ÖÐʹÓÃÕâ¸öÎļþ¡£
    ¸ÅÊö
    Global.asax λÓÚÓ¦Óà ......

£¨×ª£©ASP.NET URL Rewrite. URLÖØд


ASP.NET URL Rewrite. URLÖØд
ת×Ô£ºhttp://www.cnblogs.com/rickel/archive/2007/02/04/639616.html

URL ÖØдÊǽØÈ¡´«Èë Web ÇëÇó²¢×Ô¶¯½«ÇëÇóÖض¨Ïòµ½ÆäËû URL µÄ¹ý³Ì¡£
  ±ÈÈçä¯ÀÀÆ÷·¢À´ÇëÇóhostname/101.aspx £¬·þÎñÆ÷×Ô¶¯½«Õâ¸öÇëÇóÖж¨ÏòΪhttp://hostname/list.aspx?id=101¡£
urlÖØдµÄÓŵãÔÚ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ