ͨ¹ýASP.NET»ñÈ¡URLµØÖ·
Èç¹û²âÊÔµÄurlµØÖ·ÊÇhttp : //www.test.com/testweb/default.aspx, ½á¹ûÈçÏ£º
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PhysicalApplicationPath: E:\WWW\testwebRequest.PhysicalPath:
Request.PhysicalPath: E:\WWW\testweb\default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUrl: http://www.test.com/testweb/default.aspx
Request.Url.Host: www.test.com
Request.Url.LocalPath: /testweb/default.aspx
網Ö·£ºhttp://localhost:1897/News/Press/Content.aspx/123?id=1#toc
Request.ApplicationPath
/
Request.PhysicalPath
D:\Projects\Solution\web\News\Press\Content.aspx
System.IO.Path.GetDirectoryName(Request.PhysicalPath)
D:\Projects\Solution\web\News\Press
Request.PhysicalApplicationPath
D:\Projects\Solution\web\
System.IO.Path.GetFileName(Request.PhysicalPath)
Content.aspx
Request.CurrentExecutionFilePath
/News/Press/Content.aspx
Request.FilePath
/News/Press/Content.aspx
Request.Path
/News/Press/Content.aspx/123
Request.RawUrl
/News/Press/Content.aspx/123?id=1
Request.Url.AbsolutePath
/News/Press/Content.aspx/123
Request.Url.AbsoluteUri
http://localhost:1897/News/Press/Content.aspx/123?id=1
Request.Url.Scheme
http
Request.Url.Host
localhost
Request.Url.Port
1897
Request.Url.Authority
localhost:1897
Request.Url.LocalPath
/News/Press/Content.aspx/123
Request.PathInfo
/123
Request.Url.PathAndQuery
/News/Press/Content.aspx/123?id=1
Request.Url.Query
?id=1
Request.Url.Fragment
Request.Url.Segments
/
News/
Press/
Content.aspx/
123
Ïà¹ØÎĵµ£º
1. Get(¼´Ê¹ÓÃQueryStringÏÔʽ´«µÝ)
·½Ê½£ºÔÚurlºóÃæ¸ú²ÎÊý¡£
Ìص㣺¼òµ¥¡¢·½±ã¡£
ȱµã£º×Ö·û´®³¤¶È×Ϊ255¸ö×Ö·û£»Êý¾Ýй©ÔÚurlÖС£
ÊÊÓÃÊý¾Ý£º¼òµ¥¡¢ÉÙÁ¿¡¢¹Ø¼üµÄÊý¾Ý¡£
ÊÊÓ÷¶Î ......
1£ºÔÚ.aspxÒ³Ã棬<% %>±êÇ©Ï൱ÓÚÔÚ.csÒ³ÃæµÄ´úÂ룬Ҳ¾ÍÊÇ˵ÄãÔÚ.csÎļþÀïÃæÔõÑùд£¬¾Í¿ÉÒÔÔÚ.aspxÎļþÀïÃæµÄ<% %>±êÇ©ÀïÃæÔõÑùд¡£
2£ºÔÚ.aspxÒ³Ã棬<%= %>±êÇ©¿ÉÒÔµ÷ÓÃÄãµÄºǫ́µÄ±äÁ¿»òÕß·½·¨µÈ£¬²»¹ý±»µ÷Óõķ½·¨±ØÐëÊÇpublicµÄ¡£
Èç¹ûÄãµÄDefault.csÎļþÀïÃæÓУº
public string str = "µ÷Óúǫ́·½ ......
Ê×ÏÈÃèÊöÒ»ÏÂÎÊÌâ:ÒòΪ¿Í»§µÄÐèÒª,°ÑËùÓжÔÓÚÊý¾Ý¿âµÄ²Ù×÷×ö³ÉÁË´æ´¢¹ý³Ì,ͬʱҲ´æÔÚ´øÓÐÊäÈë²ÎÊýµÄ´æ´¢¹ý³Ì.¿Í»§ÒªÇó½«ËùÓеÄÐÅÏ¢¶¼¿ÉÒÔÓÃË®¾§±¨±íÏÔʾ.ÎÒÃǶ¼ÖªµÀ,ҪʹÓÃË®¾§±¨±íÎÒÃǾÍҪʹÓÃÊý¾ÝÔ´µÄ.ÔÚÕâÀï,ÎÒÃÇʹÓõÄÊý¾ÝÔ´×ÔÈ»¶øȻҲ¾ÍÊÇ´æ´¢¹ý³ÌÁË.µ±È»,ÎÒÃÇÒ²ÊÇÖªµÀµÄ,ÔÚADO.NETµÄÁ ......
asp.net×°Ôؽø¶ÈÌõ¼°¹¤×÷Ò³Ãæ¿ò¼ÜÖ÷ÒªÓÉ4¸ö²¿·Ö×é³É,Õâ4¸ö²¿·ÖµÄÃû³Æ¼°ÔÚÕû¸ö¿ò¼ÜÖÐËùÆðµ½µÄ×÷ÓÃÈçÏÂ:
1.Èë¿ÚÁ´½ÓµØÖ·Ò³Ãæ(aspx):±ÈÈç,µÇ¼ҳÃæ.Ìṩµ½Ä¿±êµØÖ·µÄÒ»¸öÁ´½Ó,²¢Ïò¸ÃÄ¿±ê´«µÝһЩÆô¶¯±ØÐëµÄ»ù±¾Á´½Ó²ÎÊý.
2.Èë¿ÚÁ´½ÓÄ¿±êÒ³Ãæ(aspx):¸ÃÄ¿±ê¶ÔÏóÊÇÕû¸ö¿ò¼ÜµÄºËÐÄ,Ò³Ãæ×°ÔØʱͨ¹ýdocument.writeÊä³ö2¸öiframe,Æä ......
ASP.NET 4µÄWeb Formsµ±ÖУ¬×îÁîÈ˼¤É͵ģ¬ÔòĪ¹ýÓÚÊÇURL Routing»úÖƵÄÈ«ÃæÖ§³Ö¡£¹ýÈ¥ÔÚASP.NET 3.5 SP1µ±ÖУ¬Web Forms»ò¶à»òÉپͿªÊ¼Ö§³ÖURL Routing»úÖÆ£¬ËüÈÃÎÒÃÇÔÚÍøÖ·µÄ³ÊÏÖÒÔ¼°Ê¹ÓÃÉϸü¼ÓµÄÓе¯ÐÔ¡£
¹ýÈ¥ÎÒÃÇÔÚASP.NETµ±ÖУ¬Ï°¹ßÓÚµ×ÏÂÕâÑùµÄÍøÖ·³ÊÏÖ·½Ê½£º
http://myWebSite/EditProduct.aspx?Id=1
µ«×î½ü¼¸ÄêR ......