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

¡¶ASP.NET MVC ÈëÃÅϵÁн̡̳·

ʲôÊÇMVCģʽ
MVC£¨Model-View-Controller£¬Ä£ÐÍ—ÊÓͼ—¿ØÖÆÆ÷ģʽ£©ÓÃÓÚ±íʾһÖÖÈí¼þ¼Ü¹¹Ä£Ê½¡£Ëü°ÑÈí¼þϵͳ·ÖΪÈý¸ö»ù±¾²¿·Ö£ºÄ£ÐÍ£¨Model£©£¬ÊÓͼ£¨View£©ºÍ¿ØÖÆÆ÷£¨Controller£©¡£
ÄÇôMVCģʽºÍÎÒÃÇÊìϤµÄWebFormģʽÓÐʲô²»Í¬ÄØ£¿ËûµÄ¸÷¸ö²¿·ÖÓÖÊÇÔõÑù·Ö¹¤µÄÄØ£¿
ÎÒÃÇÏÈÀ´¿´Ò»ÏÂÆÕͨµÄWebFormģʽÏ£¬ÎÒÃÇÇëÇóÒ»¸öÀýÈçhttp://www.51mvc.com/blog/index.aspxµÄURL£¬ÄÇôÎÒÃǵÄWebForm³ÌÐò»áµ½ÍøÕ¾¸ùĿ¼ÏÂȥѰÕÒblogĿ¼ÏµÄindex.aspxÎļþ£¬È»ºóÓÉindex.aspxÒ³ÃæµÄCodeBehindÎļþ(.CSÎļþ)½øÐÐÂß¼­´¦Àí£¬ÆäÖлòÐíÒ²°üÀ¨µ½Êý¾Ý¿âȥȡ³öÊý¾Ý(ÆäÖеľ­¹ýÔõÑùµÄBLLµ½DALÕâÀï¾Í²»Ì¸ÁË)£¬È»ºóÔÙÓÉindex.aspxÒ³ÃæÀ´³ÊÏÖ¸øÓû§¡£¼òµ¥µÄʾÒâͼÈçÏÂËùʾ£º
 
Ò²¾ÍÊÇÒ»¸öURLÇëÇóµÄÊÇÔÚ·þÎñÆ÷Óë¸ÃURL¶ÔӦ·¾¶ÉϵÄÎïÀíÎļþ(ASPXÎļþ»òÆäËû)£¬È»ºóÓɸÃÎļþÀ´´¦ÀíÕâ¸öÇëÇó²¢·µ»Ø½á¹û¸ø¿Í»§¶Ë¡£
µ«ÊÇ£¬¶ÔÓÚMVCģʽ£¬ÕâÊÇÔõÑùµÄÒ»¸ö¹ý³ÌÄØ£¿
ÎÒÃÇÏÈÀ´½¨Ò»¸öASP.NET MVCµÄÏîÄ¿°É¡£VS2008ĬÈÏÊÇûÓÐASP.NET MVCµÄÏîÄ¿Ä£°åµÄ£¬Ê×ÏÈÎÒÃÇÐèÒªµ½http://www.microsoft.com/downloads/details.aspx?FamilyId=A24D1E00-CD35-4F66-BAA0-2362BDDE0766&displaylang=enÈ¥ÏÂÔØ×îеÄASP.NET MVCµÄ°²×°³ÌÐò£¬Ä¿Ç°×îа汾µÄMicrosoft ASP.NET MVC Beta(10/15/2008)¡£ÏÂÔØ°²×°Íêºó£¬ÎÒÃÇ¿ÉÒÔÔÚн¨ÏîÄ¿ÄÇÀïÕÒµ½ASP.NET MVCµÄÏîÄ¿£º
 
×¢£ºÈç¹ûÄãµÄÊÇÖÐÎÄ°æµÄVS£¬°²×°Íêºó¿ÉÄÜ»á³öÏÖÕÒ²»µ½Õâ¸öÄ£°åµÄÏÖÏó£¬Äã¿ÉÒԲο¼ÔÚÖÐÎÄ°æVS 08Öа²×°MVCÕâƪÎÄÕÂÉèÖÃһϡ£
½¨Á¢Ò»¸öASP.NET MVCÏîÄ¿ºó£¬Ä¬ÈϵÄÏîÄ¿´ó¸ÅÈçÏÂͼ£º
 
ÎÒÃÇ¿ÉÒÔ¿´µ½ÏîÄ¿ÖÐÓм¸¸öÎļþ¼ÐµÄÃüÃûºÍMVC£¨Model-View-Controller£¬Ä£ÐÍ—ÊÓͼ—¿ØÖÆÆ÷ģʽ£©ÊǶÔÓ¦µÄ¡£È»ºóÎÒÃÇÔËÐÐÒ»ÏÂÏîÄ¿¿´¿´£º
 
ÎÒÃÇ×¢Òâµ½µØÖ·À¸µÄURLÊÇ Home/Index,Èç¹û°´ÕÕÎÒÃÇÇ°Ãæ˵µÄWebFormµÄģʽµÄ»°£¬ÎÒÃÇÓ¦¸Ã¿ÉÒÔÔÚÎÒÃǵÄÏîÄ¿µÄ¸ùĿ¼ÏÂÕÒµ½HomeĿ¼£¬È»ºóHomeĿ¼ÏÂÓиöIndexµÄÎļþ£¬µ«ÊÇÎÒÃDz¢²»ÄÜÔÚ¸ùĿ¼ÏÂÕÒµ½HomeÕâ¸öĿ¼¡£²»¹ý»¹ÊÇÈÃÎÒÃÇÔÚViewsĿ¼ÏÂÕÒµ½ÁËViews/Home/Index.aspxÎļþ£¬ÎÒÃÇÊäÈëÕâ¸öµØÖ·ÔËÐп´¿´£º
 
Oh£¬No£¡Â·¾¶ÊǶԵģ¬ÎļþÒ²´æÔÚ£¬µ«ÎªÊ²Ã´»áÊÇ404,˵ÕÒ²»µ½ÎļþÄØ£¿Èç¹û²»ÊÇÖ±½Ó·ÃÎÊ´æÔÚµÄÎïÀíÎļþ£¬ÄÇôMVCÓÖÊÇÔõÑù¹¤×÷µÄÄØ£¿
Ô­À´°¡£¬MVCģʽµÄ¹¤×÷¹ý³ÌÊÇÕâÑùµÄ£º
 
ÔÚMVCÖУ¬¿Í»§¶ËµÄËùÇëÇóµÄURLÊDZ»Ó³Éäµ½ÏàÓ¦µÄControllerÈ¥£¬È»ºóÓ


Ïà¹ØÎĵµ£º

ASP.NETÒ³Ãæ´«Öµ_µÚ°Ëƪ_WebConfig

+++ ÐÞ¸ÄWebConfigÎļþ£º
<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="connStr" value="Data Source=ora11g;uid=scott;pwd=tiger;unicode=true"/>
  </appSettings>
  <connectionStrings>
    <ad ......

asp.netÑéÖ¤ÂëÖÆ×÷ʵÀý´úÂë

Ч¹ûͼ
Default.aspxÒ³ÃæµÄÄÚÈÝ
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Verify._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www. ......

ASP.NET LinkButton¿Ø¼þʵÏÖurl µØÖ·¶¯Ì¬Ìøת

·½·¨Ò»£º<asp:LinkButton runat="server" ID="lbtnClick" PostBackUrl='<%#"~/test.aspx?id="+Eval("id")%>'>zhang</asp:LinkButton>
·½·¨¶þ£º<asp:LinkButton runat="server" ID="lbtnClick" PostBackUrl='<%#Eval("id","~/test.aspx?id={0}")%>'>zhang</asp"LinkButton> ......

ÐÂÊÖ¸ú×ÅѧAsp.net MVC2 Route

MVC2 ¿ò¼Ü°²×°Íê³ÉÒÔºóÎÒÃǾͿÉÒÔ¿ªÊ¼ÎÒÃÇµÄ MVCÖ®ÂÃÁË£¬ºÇºÇ
±¾´ÎѧϰÄÚÈÝ£ºRoute
Ê×ÏÈ route µÄÖÐÎÄÒâ˼¾ÍÊÇÎÒÃdz£ËµµÄ“·ÓÉ”£¬È·ÊµÕâÀïÒ²ÊÇÕâ¸öÒâ˼£¬ÔÚÎÒÃÇMVCÖÐÒѾ­²»ÔÙʹÓà XX.aspx À´·ÃÎÊÒ³ÃæÁË£¬
ËùÓÐÒ³ÃæµÄÇëÇó»áͨ¹ýrouteÀ´½âÎöÕÒµ½¶ÔÓ¦µÄ¿ØÖÆÆ÷(controller)ÀïÃæ¶ÔÓ¦µÄ²Ù×÷(action)À´Ö´Ðеġ£
mv ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ