¶¨ÖÆASP.Net MVCµÄ´úÂëÄ£°å
ÔÚASP.Net MVCÀàÐ͵ÄÏîÄ¿ÖÐÓÒ»÷Controller Îļþ¼Ð£¬Ñ¡ÖÐAdd=>Controller¡ºó£¬»áÔÚн¨µÄController ÖвåÈëһЩĬÈÏ´úÂë¡£ ÔÚController µÄ¸÷¸öAction·½·¨ÖÐÓÒ»÷ Add View¡£¬Ò²»áÔÚн¨µÄViewÖвåÈëһЩ´úÂë¡£ÔÚн¨Viewʱ²åÈëµÄ´úÂë»á¸ù¾ÝÉÏÏÂÎĺÍÄãµÄÑ¡Ôñ¶ø²»Í¬£¬ËƺõÓкܴóµÄ´úÂëÉú³É¹¦ÄÜ¡£ ÉÏÊöÁ½ÕßÉú³É´úÂëʱ¶¼Óõ½ÁËVisual StudioµÄ T4 ´úÂëÉú³ÉÄ£°å£¬T4Ä£°åºÍCodesmithÄ£°åµÄÔÀí²î²»¶à¡£T4Ä£°åÉú³É´úÂ빦ÄÜÔç¾ÍÔÚVSÖÐÓÐÁË£¬Ö»ÊǺÜÉÙΪÈËËùÖª£¬ÕæÊÇVSµÄÒ»ÏîÒþ²Ø¹¦ÄÜ¡£ÒÔÉÏÁ½ÏÄÜʹÓõÄÄ£°å¶¼ÔÚC:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates Ŀ¼Ï¡£ ½«CodeTemplatesµÄÕû¸öĿ¼¸´ÖƳöÀ´·ÅÈëÏîÄ¿Ï¡£ ÎÒÃÇ¿ÉÒÔÐÞ¸ÄÕâÀïµÄÄ£°å£¬Ò²¿ÉÒÔÌí¼Ó×Ô¼ºµÄÄ£°å£¬ÔÚÌí¼Ó´úÂëʱ¿ÉÒÔÑ¡ÔñÄĸöÄ£°å¡£ÕâÑù¾ÍʵÏÖÁ˶¨ÖÆASP.Net MVCµÄ´úÂëÄ£°å¡£
Ïà¹ØÎĵµ£º
ASP.NETÎļþÏÂÔغ¯ÊýʹÓÃÊÇʲôÇé¿öÄØ£¿ÔÚÄãµÄPage_LoadÖÐÌí¼ÓÕâÑùµÄ´úÂë:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "Ä¿µÄÎļþÃû³Æ", @"Ô´Îļþ·¾¶", 1024000);
if (!success) Response.Write("ÏÂÔØÎļþ³ö´í£¡"); Page.Response.End();
ASP.NETÎļþÏÂÔغ¯Êý´úÂëΪ:
......
ʲôÊÇMVCģʽ
MVC£¨Model-View-Controller£¬Ä£ÐÍ—ÊÓͼ—¿ØÖÆÆ÷ģʽ£©ÓÃÓÚ±íʾһÖÖÈí¼þ¼Ü¹¹Ä£Ê½¡£Ëü°ÑÈí¼þϵͳ·ÖΪÈý¸ö»ù±¾²¿·Ö£ºÄ£ÐÍ£¨Model£©£¬ÊÓͼ£¨View£©ºÍ¿ØÖÆÆ÷£¨Controller£©¡£
ÄÇôMVCģʽºÍÎÒÃÇÊìϤµÄWebFormģʽÓÐʲô²»Í¬ÄØ£¿ËûµÄ¸÷¸ö²¿·ÖÓÖÊÇÔõÑù·Ö¹¤µÄÄØ£¿
ÎÒÃÇÏÈÀ´¿´Ò»ÏÂÆÕͨµÄWebFormģʽÏ£ ......
ÔÚwebconfigÖÐÓÐÒ»¸öÖØÒª½Úµã <system.web> ÆäÖаüÀ¨ÁËÒ»¸öÉí·ÝÑéÖ¤ÅäÖýڵã
<authentication mode="Windows"/>
ÆäÖÐ authentication ÊǽڵãÃû£¬modeÊÇģʽ£¬ÉÏÊö´úÂë±íʾ ²ÉÓÃwindowsÉí·ÝÑéÖ¤£¬ÄÇô´ËʱÉí·ÝÑéÖ¤½«½»¸øiis´¦Àí£¬¶øiisÖÐĬÈÏÉè
<authentication mode="Forms" >
&n ......