ASP.NET MVC¹Ù·½Ö¸ÄÏѧϰ×ܽá
MVC¿ò¼ÜͼÈçÏ£º
ÔÚÄã¾ö¶¨Ê¹ÓÃMVC¿ò¼Ü»òWeb Formsģʽ¿ª·¢Ö®Ç°£¬ÇëÈÏÕæºâÁ¿Ò»Ï¸÷×ÔµÄÓŵ㡣
»ùÓÚMVCµÄWebÓ¦ÓóÌÐòÓŵ㣺
ËüÄܺÜÈÝÒ׵ĹÜÀí¸´ÔÓµÄÓ¦ÓóÌÐò£¬½«Ëü·ÖΪmodel£¬viewºÍcontroller¡£
Ëü²»ÄÜʹÓÃview stateºÍ·þÎñÆ÷¿Ø¼þ£¬ÕâʹµÃMVC¿ò¼Ü¿ª·¢ÈËÔ±ÓµÓжÔÓ¦ÓóÌÐòÍêÈ«¿ØÖƵÄÄÜÁ¦¡£
ËüʹÓÃÇ°¶Ë¿ØÖÆÆ÷ģʽ£¬Í¨¹ýµ¥Ò»µÄ¹ý³Ì´¦ÀíWebÓ¦ÓóÌÐòµÄÇëÇó£¬ÕâʹÄã¿ÉÒÔʹÓ÷ḻµÄURL routingÀ´Éè¼ÆÓ¦ÓóÌÐò¡£¸ü¶àÐÅÏ¢¿ÉÒÔÔÚMSDNÕ¾µãµÄFront Controller²é¿´¡£
Ëü¶Ô²âÊÔÇý¶¯¿ª·¢£¨TDD£©Ìṩ¸üºÃµÄÖ§³Ö¡£
Ëü¿ÉÒÔÈÃWeb¿ª·¢ÕߺÍÒ³ÃæÉè¼ÆÈËÔ±¿ØÖÆ×Ô¼º¹ØÐĵŤ×÷£¬´ÓÒ³ÊʺϴóÐÍÍŶӵĿª·¢¡£
»ùÓÚWeb Forms WebÓ¦ÓóÌÐòµÄÓŵ㣺
Ëü¿ÉÒÔÖ§³ÖʼþÄ£ÐͲ¢±£´æHTTPµÄ״̬£¬ÒæÓÚÏßÐÔÒµÎñµÄWebÓ¦ÓóÌÐò¿ª·¢£¬»ùÓÚWeb FormsÓ¦ÓóÌÐòÌṩÁËÐíÐí¶à¶àµÄʼþºÍÉÏ°ÙÖֵķþÎñÆ÷¿Ø¼þ¡£
ËüʹÓÃÒ³Ãæ¿Ø¼þÆ÷ģʽ£¬ÔÚµ¥¸öÒ³ÃæÖÐʵÃæºÜ¶àµÄ¹¦ÄÜ¡£¸ü¶àÐÅÏ¢Çë²Î¿¼MSDNÕ¾µãÉϵÄPage Controller¡£
ËüʹÓÃview stateºÍ»ùÓÚ·þÎñÆ÷µÄ±íµ¥£¬Ê¹µÃ¹ÜÀíÒ³Ãæ״̬ÐÅÏ¢¸ü¼ÓÈÝÒס£
ËüÊʺÏСµÄ¿ª·¢ÍŶӣ¬Ê¹Óø߶ȼ¯³ÉµÄ¿Ø¼þÀ´Ìá¸ßWebÉè¼ÆÈËÔ±ºÍÍøÒ³Éè¼ÆÈËÔ±µÄЧÂÊ¡£
Ò»°ãÀ´Ëµ£¬ËüÊʺϲ»ÊÇÄÇô¸´ÔÓµÄÓ¦ÓóÌÐò¿ª·¢£¬ÒòΪËüµÄÒ³ÃæÀàºÍ¿Ø¼þÀàÊǺϲ¢ÔÚÒ»ÆðµÄ£¬ËùÒÔÏà¶ÔÓÚMVCģʽÀ´ËµËüÐèÒª±àдµÄ´úÂë¸üÉÙ¡£
Asp.net MVCÖ§³ÖASP.NET¿ò¼ÜµÄÌØÐÔ£º
formsµÄÉí·ÝÑéÖ¤ºÍWindowsµÄÉí·ÝÑéÖ¤¡£
URLÑéÖ¤¡£
MembershipºÍroles¡£
Êä³öºÍÊý¾Ý»º´æ¡£
sessionºÍprofile״̬¹ÜÀí¡£
½¡¿µ×´Ì¬¼à¿Ø¡£
configurationϵͳºÍprovider¼Ü¹¹¡£
ÒÔϱí¸ñÊÇASP.NET MVCÖ´ÐÐÖÜÆÚÖÐËù´¦µÄ½×¶Î£º
½×¶Î
½éÉÜ
ÊÕµ½µÚÒ»´ÎÇëÇó
ÔÚGlobal.asaxÎļþÖн«Route¶ÔÏóÒÀ´ÎÔö¼Óµ½RouteTable¶ÔÏó¡£
Ö´ÐзÓÉ
UrlRoutingModuleÄ£¿éÏÈ´ÓRouteTable¼¯ºÏÖÐÒÀ´ÎÆ¥ÅäRoute£¬Èç¹ûÆ¥Åäµ½ºó¾Í´´½¨RouteData¶ÔÏó£¬È»ºóʹÓÃËüÀ´´´½¨RequestContext£¨IHttpContext£©¶ÔÏó¡£
´´½¨ÇëÇóMVC´¦ÀíÄ£¿é
MvcRouteHandler¶ÔÏó´´½¨Ò»¸öMvcHandlerµÄʵÀýÀàÐͲ¢´«ÈëRequestContextµÄʵÀý
´´½¨controller
MvcHandler¶ÔÏóʹÓÃRequestContextʵÀýÒÔÈ·¶¨IControllerFactory¶ÔÏó£¨Í¨³£ÊÇDefaultControllerFactoryÀàµÄʵÀý£©À´´´½¨controllerʵÀý¡£
Ö´ÐÐcontroller
The MvcHandler instance calls the controller's Execute method.
MvcHandlerʵÀýµ÷ÓÃcontrollerµÄExecute·½·¨¡£
µ÷ÓÃaction
´ó¶àÊý¿ØÖÆÆ÷¼Ì³Ð×ÔController»ùÀ࣬Contro
Ïà¹ØÎĵµ£º
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ÖØдµÄÓŵãÔÚ ......
¿ÉÒÔʹÓà ISAPI ɸѡÆ÷ÔÚ IIS Web ·þÎñÆ÷¼¶±ðʵÏÖ URL ÖØд£¬Ò²¿ÉÒÔʹÓà HTTP Ä£¿é»ò HTTP ´¦Àí³ÌÐòÔÚ
ASP.NET ¼¶±ðʵÏÖ URL ÖØд¡£±¾ÎÄÖصã½éÉÜÈçºÎʹÓà ASP.NET ʵÏÖ URL ÖØд£¬Òò´ËÎÒÃǽ«²»¶ÔʹÓà ISAPI ɸѡÆ÷ʵÏÖ
URL ÖØдµÄϸ½Ú½øÐÐÉîÈë̽ÌÖ¡£µ«ÊÇ£¬ÓдóÁ¿µÄµÚÈý·½ ISAPI ɸѡÆ÷¿ÉÓÃÓÚ URL ÖØд£¬ÀýÈ磺 ......
1.//µ¯³ö¶Ô»°¿ò.µã»÷תÏòÖ¸¶¨Ò³Ãæ
Response.Write(" <script>window.alrt('¸Ã»áԱûÓÐÌá½»ÉêÇë,ÇëÖØÐÂÌá½»£¡') </script>"); Response.Write(" <script>window.loation='http://www.cnblogs.com/kevin1031" target="_blank">http://www.cnblogs.com/kevin1031' </script>");
2.//µ¯³ö¶Ô»°¿ ......
asp.net ʵÏÖ¶¨Ê±Ö´ÐÐ Ò»¸ö·½·¨
public class Time_Task
{
public event System.Timers.ElapsedEventHandler ExecuteTask;
private static readonly Time_Task _task = null;
private System.Timers.Timer _timer = null;
privat ......
1. ·ÃÎÊ HTML¿Ø¼þµÄÖµÊÇvalueÊôÐÔ
·ÃÎÊ ASP.NET¿Ø¼þµÄÖµÊÇtextÊôÐÔ
--------------------------------------------------------
2.·Ö±ðÐèÒªµÄÃû×Ö¿Õ¼äΪ£º
using System.Web.UI.HTML.Controls;
using System.Web.UI.WebControls;
-------------------------------------------- ......