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

ASP.NET 4µ±ÖÐUrl RoutingµÄÖ§Ô®

ASP.NET 4µÄWeb Formsµ±ÖУ¬×îÁîÈ˼¤É͵ģ¬ÔòĪ¹ýÓÚÊÇURL Routing»úÖƵÄÈ«ÃæÖ§³Ö¡£¹ýÈ¥ÔÚASP.NET 3.5 SP1µ±ÖУ¬Web Forms»ò¶à»òÉپͿªÊ¼Ö§³ÖURL Routing»úÖÆ£¬ËüÈÃÎÒÃÇÔÚÍøÖ·µÄ³ÊÏÖÒÔ¼°Ê¹ÓÃÉϸü¼ÓµÄÓе¯ÐÔ¡£
¹ýÈ¥ÎÒÃÇÔÚASP.NETµ±ÖУ¬Ï°¹ßÓÚµ×ÏÂÕâÑùµÄÍøÖ·³ÊÏÖ·½Ê½£º
http://myWebSite/EditProduct.aspx?Id=1
µ«×î½ü¼¸ÄêREST·ç¸ñµÄÍøÕ¾(»òREST Web·þÎñ)ÐËÆð£¬Äã³£³£»á¿´µ½ÍøÖ·µÄ³ÊÏÖ·½Ê½±ä³É£º
http://myWebSite/Product/Edit/XBOX
ÉÏÃæÕâÑùµÄÍøÖ·ÓÐһЩºÃ´¦£¬Ê×ÏÈ£¬ÍøÖ·¿ÉÒÔ¸üÃ÷È·µÄ±í´ïÏëÒª³ÊÏֵŦÄÜ£¬»òÊÇÒªºó¶ËÓ¦ÓóÌÐò½øÐеÄÐÐΪ£»Æä´Î£¬ÉÏÃæÕâÑùµÄÍøÖ·ÓÉÓÚ²¢·Ç¶ÔÓ¦µ½ºó¶Ëijһ¸öʵÌåµµ°¸(.aspx.cs)£¬¶øÊÇ͸¹ýRouting»úÖÆÀ´×ªÅÉ£¬Òò´ËÏà½Ï¹ýÈ¥µÄÍøÖ·ÓÐןü¸ßµÄ°²È«ÐÔ¡£
Ò²¾ÍÊÇ˵£¬ÔÚÕâÑùµÄ¼Ü¹¹Ï£¬ASP.NETÓ¦ÓóÌÐòµÄÍøÖ·ÔÙÒ²²»Ö»ÊǶÔÓ¦µ½ÊµÌåµµ°¸µÄ·¾¶£¬¶øÊÇ¿ÉÓÃÀ´±í´ïÒªÖ´ÐеŦÄÜ¡£ÖÁÓÚʵ¼ÊÖ´ÐÐʱҪ´¦ÀíµÄ³ÌÐò´úÂë»ò³ÊÏÖ½á¹ûµÄÍøÒ³£¬Ò²²¢·ÇÒ»¶¨ÒªÊÇÓÉÍøÖ·ËùÖ¸ÏòµÄʵÌåÒ³Ãæ¡£ÕâÒ²ÈÃÎÒÃÇÔÚ¿ª·¢Ó¦ÓóÌÐòʱÓиü´óµÄµ¯ÐÔ£¬ÀýÈçÒ»°ãµÄ²¿Âä¸ñÍøÕ¾ÍøÖ·¿ÉÄÜÊÇ¡ºhttp://blog/studyhost¡»£¬ÓÉÓÚblogÍøÕ¾¶à°ë¶¼¿ÉÒÔ¿ª·Å¸ø¶àÈËÉêÇ룬ÀíËùµ±È»µÄÿһ¸öÓû§¶¼ÓÐÀàËÆ¡ºhttp://blog/ÉêÇëÕßID¡»ÕâÑùµÄÍøÖ·¡£µ±È»£¬¶ÔÓ¦µ½ASP.NETµÄºó¶ËÓ¦¸Ã¶¼ÊÇͬһÌ׳ÌÐòÀ´´¦Àí£¬ÔÚ¹ýÈ¥µÄASP.NETÓ¦ÓóÌÐòµ±ÖУ¬ÎÒÃǵÃҪɷ·ÑÒ»·¬¹¤·ò²ÅÄÜÈÃÍøÕ¾¿ÉÒÔ½ÓÊÜÕâÑùµÄÍøÖ·Éè¼Æ(°Ñ²ÎÊý´ÓQueryStringת±ä³ÉREST·ç¸ñ)£¬¶øÏÖÔÚ£¬Í¸¹ýURL Routing»úÖƺܿìµØ¾ÍÄÜÇáËɸ㶨¡£
³ý´ËÖ®Í⣬»¹ÓÐÁíÒ»¸öÏÔ¶øÒ×¼ûµÄºÃ´¦£¬²ÉÓÃREST·ç¸ñµÄÍøÖ·£º
http://myWebSite/Product/Edit/XBOX
vs.
http://myWebSite/EditProduct.aspx?Id=1
Ïà½ÏÓÚ´«Í³ÍøÖ·¸üÈÝÒ×±»GoogleµÈËÑË÷ÒýÇæ²éѯÓë¼ìË÷£¬±Ï¾¹ÉÏͼÍøÖ·ÖеÄXBOX±ÈÆð²úÆ·Id=1À´µÃÈÝÒ×Àí½âµÄ¶à¡£
ÄÇÎÒÃÇÒªÈçºÎÔÚASP.NET 4µ±ÖÐʹÓÃÕâÑùµÄ»úÖÆÄØ£¬ÄúÖ»ÐèҪ͸¹ýмÓÈëµÄRoutesÀà±ð£¬ÀûÓÃMapPageRoute·½·¨¼´¿ÉÇáÒ×µÄÍê³ÉURL·ÓɵÄÖ¸¶¨£¬ÀýÈ磺
view plaincopy to clipboardprint?
protected void Application_Start(object sender, EventArgs e) {  
    RouteTable.Routes.MapPageRoute(  
        "TestRoute", "Search/{ProductName}", "~/WebForm1.aspx");   

protected void Application_Start(object sender, EventArgs e) {
  


Ïà¹ØÎĵµ£º

Asp.netÒ¹»°Ö®Ò»£ºasp.net½éÉÜ


ÌâÍâ»°£ºÈ¥ÄêÖÁ½ñÄêÒÔÀ´£¬Â½Ðøд¹ýһЩԭ´´µÄÎÄÕÂÁË£¬ºÜ¶àÊǶÔÔ­À´Ëù×öÏîÄ¿µÄ×ܽᡣËùÒÔ²¢²»ÊǺÜϵͳºÜÈ«Ã棬¶¼ÊÇÕë¶Ôij¸ö֪ʶµã»òÕßij¸ö¾ßÌåÓ¦ÓÃдµÄ£¬ÓÐЩÅóÓѽ¨ÒéÎÒ°Ñ×Ô¼ºµÄÌå»áд³ÉÒ»¸öϵͳµÄ£¬Õâ´ÎËãÊÇÒ»¸ö³¢ÊÔ°É£¬Ð´µÃ²»ºÃµÄµØ·½Çë´ó¼Ò¾¡Á¿Å×Î÷ºìÊÁ²»Òª¶ª×©Í·¡£
Ö®ËùÒÔ°ÑÕâ¸öϵÁнÐ×ö¡¶asp.netÒ¹»°¡·£¬ÊÇÓÐÒ»Ð©Ô­Ò ......

ASP.NET(C#)³£ÓôúÂë30Àý

1. ´ò¿ªÐµĴ°¿Ú²¢´«ËͲÎÊý£º
¡¡¡¡´«ËͲÎÊý£º
response.write("£¼script£¾window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)£¼/script£¾")
¡¡¡¡½ÓÊÕ²ÎÊý£º
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
¡¡¡¡2.Ϊ°´Å¥Ìí¼Ó¶Ô»°¿ò
Button1 ......

ASP.NET MVCÀ©Õ¹¿â

ºÜ¶àͬѧ¶¼¶Á¹ýÕâƪÎÄÕ塃 ASP.NET MVCÖÐÄã±ØÐëÖªµÀµÄ13¸öÀ©Õ¹µã£¬½ñÌì¸ø´ó¼Ò½éÉÜÒ»¸öASP.NET MVCµÄÀ©Õ¹¿â£¬Ö÷Òª¾ÍÊÇÕë¶ÔÕâЩÀ©Õ¹µã½øÐС£Õâ¸öÏîÄ¿µÄºËÐÄÊÇIOCÈÝÆ÷£¬°üÀ¨Ninject, StructureMap, Unity £¬WindsorºÍAutofac¡£Èç¹ûÄãºÍÎÒÒ»Ñùϲ»¶Ê¹ÓÃIOC£¬Õâ¸ö¿âÖµµÃÄã¹Ø×¢£¬ÕâЩIOCÎÒ¶¼ÓùýÁË£¬ÏÖÔڱȽÏϲ»¶Ê¹ÓÃAutofac¡£
AS ......

ASP.NET»ñÈ¡¿Í»§¶ËIP/Óû§ÃûµÈÐÅÏ¢

1. ÔÚASP.NETÖÐרÓÃÊôÐÔ£º
»ñÈ¡·þÎñÆ÷µçÄÔÃû£ºPage.Server.ManchineName
»ñÈ¡Óû§ÐÅÏ¢£ºPage.User
»ñÈ¡¿Í»§¶ËµçÄÔÃû£ºPage.Request.UserHostName
»ñÈ¡¿Í»§¶ËµçÄÔIP£ºPage.Request.UserHostAddress
2. ÔÚÍøÂç±à³ÌÖеÄͨÓ÷½·¨£º
»ñÈ¡µ±Ç°µçÄÔÃû£ºstatic System.Net.Dns.GetHostName()
¸ù¾ÝµçÄÔÃûÈ¡³öÈ«²¿IPµØÖ ......

ÓÃAsp.netÖÆ×÷¶¥²¿µ¼º½¿Ø¼þ

Ò»¡¢Ð§¹û¼ò½é
¡¡¡¡µ±µã»÷Ò»¼¶À¸Ä¿Ê±£¨ÈçÊ×Ò³£©£¬±»µã»÷µÄÒ»¼¶À¸Ä¿µÄµ¥Ôª¸ñ±³¾°É«·¢Éú±äÉ«£¬Èç¹û¸ÃÒ»¼¶À¸Ä¿ÏÂÓжþ¼¶À¸Ä¿£¬Ôò»áÔÚÏÂÒ»ÐÐÏÔʾ³öÀ´£¬·ñÔò¶þ¼¶À¸Ä¿ÕâÒ»Ðв»»áÏÔʾÈκζ«Î÷£¬µ«»áÕ¼Ò»¶¨µÄ¸ß¶È¡£µ±µã»÷¶þ¼¶À¸Ä¿Ê±£¬ÆäËùÊôµÄÒ»¼¶À¸Ä¿µ¥Ôª¸ñ±³¾°É«·¢Éú±ä»¯£¬Í¬Ê±±»µã»÷µÄ¶þ¼¶À¸Ä¿Ãû³Æ»á¼Ó´Ö£¬²¢ÔÚÇ°·½¼ÓÒ»¸ö“¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ