SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
利用 ASP.NET MVC 提升您的
Web 應用程式
董大偉 David@studyhost.com
台灣微軟MSDN講座講師
TechED 2007, 2008講師
Develop Web Application with ASP.NET MVC
本場次大綱
從5W1H看ASP.NET MVC
什麼是MVC?
透過這樣的架構開發的應用程式有何優點?
ASP.NET MVC Framework又是什麼?
和ASP.NET WebForm技術不同嗎?
如何利用ASP.NET MVC來開發MVC應用程式?
如何撰寫出較好的Web應用程式?
解決方案總是從問題而來
- Develop Web Application with ASP.NET MVC
ASP.NET MVC的 5W 1H
WHAT - 什麼是ASP.NET MVC?
WHEN - 何時需要使用ASP.NET MVC?
WHY - 為何要使用ASP.NET MVC?
WHO - 誰適合來使用ASP.NET MVC?
WHERE - 在些場合中需要使用ASP.NET MVC?
HOW - 如何開發ASP.NET MVC 應用程式?
什麼是MVC?
- Develop Web Application with ASP.NET MVC
MVC…
是一種設計模式。
MVC這個Pattern要求我們在開發程式的時候,把我們要透過
程式碼達成的一個功能,在設計時切割成Model、View、
Controller這三個部分(的程式碼)。
每一個部分可以獨立互不干涉,但執行時可以互相合作,已
達成功能,開發時亦可由不同的開發人員進行開發、同時也
便於Unit Test。
目的:
降低程式碼之間的相依性、提高重用性
便於多人開發、單元測試、降低開發成本
結構清晰、利於後續維護
…
什麼是MVC?
- Develop Web Application with ASP.NET MVC
Controller
Model
View
什麼是MVC?
- Develop Web Application with ASP.NET MVC
ASP.NET MVC
微軟平台上新提供的MVC開發架構,透過這組
類別庫,開發人員可以MVC架構來建立Web應
用程式。這組MVC架構可以同時提高程式的延
展性與彈性,降低.aspx頁面與後端資料庫、商
業邏輯之間的相依性,達成大型專案的快速開
發、高重用性、容易調整與維護的目的。
什麼是ASP.NET MVC Framework
- Develop Web Application with ASP.NET MVC
ASP.NET MVC Framework是…
架構在ASP.NET技術上的一組Framework。
讓開發人員得以輕鬆建立出MVC架構的應用程式。
提供建構MVC應用程式所需的基礎類別、以及相關工具
(Helper) 。
概念上與ASP.NET WebForm並不相同,不支援事件驅動、
Web Controls、或是Postback…等機制。
支援了一些ASP.NET過去相當優秀的設計,例如Master-
Page、MemberShip、UserControl等機制。
ASP.NET MVC Framework
• 負責與UI顯示有關的部分,在這個部分當中的程式碼,只應該與
UI(或UI上的操作)有關,不應該有任何與商業邏輯、後端資料庫有
關的任何程式碼,對於Web應用程式來說,就是Render出HTML
與前端JavaScript操作的部分。
View
• 這個部分的程式碼可以是部分的商業邏輯、可以是應用程式當中
所需要的運算規則或演算法、Controller中的程式碼可以依照實際
的需求(功能)決定調用(或存取)哪一個Model、可以動態的決定用
哪一個View來呈現運算後的結果,Controller同時也負責回應前端
View所產生的事件(或需求)。
Controller
• 一般來說就是Data Model,同時負責了實際資料庫存取的部分,
這部分的程式碼負責把後端資料庫給封裝起來,讓Controller或
View可以完全不(需要)知道(或不在乎)後端資料庫的長相究竟為何,
只需要透過Model即可正確的存取後端資料庫。
Model
ASP.NET MVC Framework
.aspx
.aspx
.aspx
ViewData
Post
Get
Controllers
Data
Model
LinqToSql
(.dbml)
ADO.NET Entity
Framework
(.edmx)
Models
Views
Protected Sub Button_GetBMI_Click(ByVal sender As Object, ByVal e As EventArgs) Handles
Button_GetBMI.Click
Dim BMI As Single
Dim height, weight As Single
'從UI取得身高體重
height = Me.TextBox_Height.Text
weight = Me.TextBox_Weight.Text
'計算BMI(主要邏輯運算)
BMI = weight / (height / 100) ^ 2
'顯示BMI
Me.Label_Result.Text = "計算結果 BMI=" & BMI
‘將資料儲存到資料庫
SqlDataSource1.InsertCommand = "Insert into BmiData (Height,Weight,BMI) values
(@Height,@Weight,@BMI)"
SqlDataSource1.InsertParameters.Add("Height", height)
SqlDataSource1.InsertParameters.Add("Weight", weight)
SqlDataSource1.InsertParameters.Add("BMI", BMI)
'顯示訊息
If SqlDataSource1.Insert() > 0 Then
ClientScript.RegisterStartupScript(Me.GetType, "", "alert('儲存成功');", True)
Else
ClientScript.RegisterStartupScript(Me.GetType, "", "alert('儲存失敗');", True)
End If
『一氣呵成』、從前端殺到後端的『直搗狂龍式』寫法ClassicBmiWebAP
MVC三合一應用程式 
這種程式我們稱為:MVC三合一寫法
MVC三合一的問題
- Develop Web Application with ASP.NET MVC
在同一個事件當中, 又處理UI, 又處理邏輯, 又存
取DB
前端.aspx頁面與後端資料庫密不可分
前端.aspx頁面與後端商業邏輯程式碼難分難捨
即使具有DataAccess Class也難免保證開發人員
遵循(*)
牽一髮而動全身
MVC三合一的問題
- Develop Web Application with ASP.NET MVC
應該如何改進?
1. 將Business Logic獨立出來
2. 將資料庫存取部分獨立出來
結果:
1. 程式碼相依性降低、可重用性提高
2. 程式碼變多?
3. 效能會提升嗎?
DEMO:調整MVC三合一程式,使之
 將Business Logic獨立出來
 將資料庫存取部分獨立出來
 程式碼相依性降低、可重用性提高
D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCClassicBmiWebAP2
MVC的目的
- Develop Web Application with ASP.NET MVC
避免在同一段程式碼當中, 又處理UI, 又處理邏輯,
又存取DB…
降低程式之間的相依性、提高重用性
讓程式碼結構更加清晰
不同的模塊可由擅長該技術的專職開發人員進行
開發,降低開發成本,提高產能
便於Unit Test、使TDD成為可能
DEMO:建構第一個MVC應用程式
 建立ASP.NET MVC Web Application
 建立BMI Controller與Index Action
 建立ViewPage(含欄位)
 撰寫BMI Class
 在Controller中接收參數
調用BMI Class, 輸出結果
D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCBmiMvcApp
MVC希望在程式面達成的效果
View與Business Login、Model之間徹底脫鉤絕緣
透過Controller轉派
資料來源: http://images.google.com.tw/imgres?imgurl=http://ash-mvc.org/media/Image/ash-mvc-architecture.gif&imgrefurl=http://ash-
mvc.org/&h=301&w=351&sz=15&hl=zh-
TW&start=2&tbnid=SgcaMgMTQ1kRfM:&tbnh=103&tbnw=120&prev=/images%3Fq%3DMVC%26gbv%3D2%26complete%3D1%26hl%3Dzh-TW
ASP.NET MVC Framework
認識Controller
- Develop Web Application with ASP.NET MVC
負 責 接 收 Browser 端 透 過 HTTP GET/POST 傳 來 的
Request
Url可決定該Request由哪一個Controller、哪一個
Action來負責
Controller當中可以進行各種運算、亦可能包含商業邏
輯、各種演算法…等程式碼。
如果有需要,可調用Model來進行後端資料庫存取的
動作。
最後決定由哪一個View來處理結果的呈現。
同時將View需要呈現的資料透過ViewData傳遞給
View。
關於URL Routing
- Develop Web Application with ASP.NET MVC
URL Routing機制負責將Browser傳來的Request對應
到Controller與Action。
在這種設計架構下,我們可以用同一個『頁面』負責
同一種『工作』 。
可降低頁面的數量,每一個頁面(View)清楚的負責一
種『功能』,不需要撰寫許多頁面負責同樣的功能(例
如不同資料表的顯示)。
URL直接對應到『功能』 ,在邏輯上更加直覺。
http://localhost:50302/bmi/index
Web Site Controller Action
認識Controller
- Develop Web Application with ASP.NET MVC
Controller中程式碼的撰寫方式, 同名處理不同的Verbs
' HTTP GET: /Bmi/Index
Function Index() As ActionResult
(…略…)
Return View()
End Function
' HTTP POST: /Bmi/Index
<AcceptVerbs(HttpVerbs.Post)> _
Function Index(ByVal TxbHeight As Single, ByVal TxbWeight As
Single) As ActionResult
(…略…)
Return View()
End Function
使用預設的View(也就是
BMI/Index.aspx)來回應
從View欄位接收參數
關於URL Routing
- Develop Web Application with ASP.NET MVC
例如,底下的URL可以用來顯示編號為17的產品:
請注意Global.asax檔案(設定Url Route, 底下為預設)
http://store.abc.com/product/ShowDetails/17
Web Site Controller Action ID
routes.MapRoute( _
"Default", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = ""} _
)
認識Controller
- Develop Web Application with ASP.NET MVC
Controller中程式碼的撰寫方式
各種ActionResult
ViewResult, EmptyResult, RedirectResult, JavaScriptResult,
ContentResult, FileContentResult, FilePathresult, FileStreamResult, …
' GET: /product/ShowDetails
Function ShowDetails(ID As Integer) As ActionResult
'取得ID
'透過Data Model抓取資料庫中的內容
‘將資料傳遞給ViewPage
Return View()
End Function
Controller如何與View溝通?
- Develop Web Application with ASP.NET MVC
抓取ViewPage上的欄位值
' POST: /Bmi/Index
<AcceptVerbs(HttpVerbs.Post)> _
Function Index(ByVal TxbHeight As Single, ByVal TxbWeight
As Single) As ActionResult
(…略…)
'使用預設的VIew
Return View()
End Function
Controller如何與View溝通?
- Develop Web Application with ASP.NET MVC
透過ViewData將資料傳給ViewPage
' POST: /Bmi/Index
<AcceptVerbs(HttpVerbs.Post)> _
Function Index(ByVal TxbHeight As Single, ByVal TxbWeight As Single)
As ActionResult
Dim BMI As Single
Dim MyBMI As New BMI
'使用BMI類別進行運算
MyBMI.Height = TxbHeight
MyBMI.Weight = TxbWeight
BMI = MyBMI.GetBMI()
'將執行結果傳遞給View
ViewData("result") = BMI
'使用預設的VIew
Return View()
End Function
Controller如何與View溝通?
- Develop Web Application with ASP.NET MVC
透過ViewData將資料傳給ViewPage
' POST: /Bmi/Index
<AcceptVerbs(HttpVerbs.Post)> _
Function Index(ByVal TxbHeight As Single, ByVal TxbWeight As
Single) As ActionResult
(…略…)
Return View(Model)
End Function
可傳遞任何的物件給
ViewPage
認識Controller
- Develop Web Application with ASP.NET MVC
建立在Controllers資料夾中
繼承自System.Web.Mvc.Controller
負責回應Browser的各種Request
如何從ViewPage接收參數?
透過ID、透過ViewPage上的欄位
如何傳遞參數給ViewPage?
透過ViewData、透過ViewResult的Model參數
認識ViewPage
- Develop Web Application with ASP.NET MVC
負責展示層UI的顯示。
與商業邏輯運算、後端資料庫均無關。
在這個部分當中可以有程式碼,但程式碼只應該與UI(或
UI上的操作)有關,不應該有任何與商業邏輯、後端資料
庫有關的任何程式碼,對於Web應用程式來說,主要就
是Render出HTML與前端JavaScript操作的部分。
繼承於System.Web.Mvc.ViewPage 。
可透過ViewData取得來自Controller的資料。
可透過Model取得來自Controller的複雜資料。
具有HtmlHelper可使用,便於開發。
認識ViewPage
- Develop Web Application with ASP.NET MVC
與過去ASP類似的程式撰寫方式
可透過HTML Helper協助產生需要的Html Element
不支援Web Controls
可透過ViewData抓取到Controller傳遞過來的資料
<% Using Html.BeginForm() %>
<br/>身高:<% =Html.TextBox("TxbHeight") %>
<br/>體重:<% =Html.TextBox("TxbWeight") %>
<input type="submit" value="Calculate" />
<% End Using%>
<% If ViewData("result") IsNot Nothing Then
Response.Write("BMI:" & ViewData("result")) %>
認識ViewPage
- Develop Web Application with ASP.NET MVC
Html Helper支援…
Html.ActionLink(linkText,ActionName,ControllerName)
Html.TextBox(name)
Html.TextArea(name)
Html.RadioButton(name,value)
Html.BeginForm()
Html.Encode(value)
…
DEMO:將MVC應用程式加入資料庫存取
 使用先前的BmiMvcApp
 加入資料庫
 調整ViewPage(新增欄位)
 加入LinqToSql Data Model(封裝資料庫)
D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCBmiMvcAppWithDB
認識Model
- Develop Web Application with ASP.NET MVC
負責了實際資料庫存取的部分。
這部分的程式碼負責把後端資料庫給封裝起來,讓
Controller或View可以完全不(需要)知道(或不在乎)後端
資料庫的長相究竟為何,只需要透過Model即可正確的
存取後端資料庫。
有效的隔離展示層程式碼與後端資料庫
可透過Bind修飾字將ViewPage上的資料繫結到
Controller的參數,以便於儲存到DB
Contoller中可透過ViewResult的Model參數將從DB取得
的資料以物件型態傳遞給ViewPage。(請注意ViewPage
須設定泛型型別)
認識Model
- Develop Web Application with ASP.NET MVC
Contoller中可透過ViewResult的Model參數將從DB取得
的資料,以物件型態傳遞給ViewPage。(請注意
ViewPage須設定泛型型別)
Dim db As New AddressBookDBDataContext
'
' HTTP GET: /AddressBook/
Function Index() As ActionResult
Return View(db.AddressBook.ToList)
End Function
認識Model
- Develop Web Application with ASP.NET MVC
承接的ViewPage,需要設定泛型型別,以便於取得資料
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage(Of IEnumerable (Of AddressBookMvcApp.AddressBook))"
%>
<% For Each item In Model%>
<tr>
<td>
<%=Html.ActionLink("Edit", "Edit", New With {.id = item.uid})%> |
<%=Html.ActionLink("Details", "Details", New With {.id = item.uid})%>
</td>
<td> <%= Html.Encode(item.uid) %> </td>
<td> <%= Html.Encode(item.cName) %> </td>
<td> <%= Html.Encode(item.cTel) %> </td>
<td> <%= Html.Encode(item.cMemo) %> </td>
</tr>
<% Next%>
</table>
</asp:Content>
認識Model
- Develop Web Application with ASP.NET MVC
儲存(回寫)資料時,亦可透過Bind修飾字將ViewPage上
的資料繫結到Controller的參數,以便於儲存到DB。
'Post: /Home/Create
<AcceptVerbs(HttpVerbs.Post)> _
Function Create(<Bind(exclude:="uid")> ByVal
TableData As AddressBookMvcApp.AddressBook) As
ActionResult
db.AddressBook.InsertOnSubmit(TableData)
db.SubmitChanges()
Return RedirectToAction("Index")
End Function
DEMO:建立資料庫處理MVC應用程式
 AddressBookMvcApp
 加入資料庫AddressBookDB.mdf
 建立Data Model
 建立並規劃AddressBook Controller
 Index – 顯示所有紀錄
 Create– 建立資料
 建立相對應的ViewPage(可用Wizard)
 撰寫Controller程式碼
D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCAddressBookMvcApp
關於Unit Test
- Develop Web Application with ASP.NET MVC
由於View與Business Logic已經切割開來,
有助於Unit Test的進行。
D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCBmiMvcApp
<TestMethod()> Public Sub TestMethod1()
Dim theBmiController As New BmiController
Dim theViewResult As ViewResult =
theBmiController.Index(170, 70)
Assert.AreEqual("24.22145",
theViewResult.ViewData("result").ToString)
End Sub
解決方案總是從問題而來
- Develop Web Application with ASP.NET MVC
ASP.NET MVC的 5W 1H
WHAT - 什麼是ASP.NET MVC?
WHEN - 何時需要使用ASP.NET MVC?
WHY - 為何要使用ASP.NET MVC?
WHO - 誰適合來使用ASP.NET MVC?
WHERE - 在些場合中需要使用ASP.NET MVC?
HOW - 如何開發ASP.NET MVC 應用程式?
Summary
MVC架構有助於降低程式碼相依性,提高重用性
讓系統便於測試、可同時多人開發、降低開發成本
程式碼長度(數量)並不會減少、效能不一定會提升
適合大型(或超大型)的應用系統
MVC著重於架構、並非開發的速度、但當系統規模
大到一定程度之後,MVC架構有助於提高產能
將適合的技術用在適當的場合…
ASP.NET MVC相關資源
筆者 BLOG http://blog.studyhost.com/
筆者 RUN!PC ASP.NET 3.5 SP1-4.0專欄
ASP.NET網站MVC篇:
http://www.asp.net/mvc/
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market
conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT
MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Weitere ähnliche Inhalte

Was ist angesagt?

Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4
Kyle Shen
 

Was ist angesagt? (18)

ASP.NET MVC之實戰架構探討 -twMVC#5
ASP.NET MVC之實戰架構探討 -twMVC#5ASP.NET MVC之實戰架構探討 -twMVC#5
ASP.NET MVC之實戰架構探討 -twMVC#5
 
與 Asp.net mvc 的第一次親密接觸 - twMVC#1
與 Asp.net mvc 的第一次親密接觸 - twMVC#1與 Asp.net mvc 的第一次親密接觸 - twMVC#1
與 Asp.net mvc 的第一次親密接觸 - twMVC#1
 
ASP.NET MVC 新增、查詢、修改、刪除 基本功實戰 -twMVC#3
ASP.NET MVC 新增、查詢、修改、刪除 基本功實戰 -twMVC#3ASP.NET MVC 新增、查詢、修改、刪除 基本功實戰 -twMVC#3
ASP.NET MVC 新增、查詢、修改、刪除 基本功實戰 -twMVC#3
 
架構行動式網站(使用 ASP.NET MVC 4.0 -twMVC#6
架構行動式網站(使用 ASP.NET MVC 4.0 -twMVC#6架構行動式網站(使用 ASP.NET MVC 4.0 -twMVC#6
架構行動式網站(使用 ASP.NET MVC 4.0 -twMVC#6
 
ASP.NET MVC Code Templates實戰開發 -twMVC#4
 ASP.NET MVC Code Templates實戰開發 -twMVC#4 ASP.NET MVC Code Templates實戰開發 -twMVC#4
ASP.NET MVC Code Templates實戰開發 -twMVC#4
 
Asp.net mvc 從無到有 -twMVC#2
Asp.net mvc 從無到有 -twMVC#2Asp.net mvc 從無到有 -twMVC#2
Asp.net mvc 從無到有 -twMVC#2
 
Mvc架構說明
Mvc架構說明Mvc架構說明
Mvc架構說明
 
ASP.NET MVC Model 的設計與使用 twMVC#10
ASP.NET MVC Model 的設計與使用 twMVC#10ASP.NET MVC Model 的設計與使用 twMVC#10
ASP.NET MVC Model 的設計與使用 twMVC#10
 
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)KSDG-ASP.NET MVC 5 Overview (偽三國誌)
KSDG-ASP.NET MVC 5 Overview (偽三國誌)
 
Study4 love.2016.2.20.ionic
Study4 love.2016.2.20.ionicStudy4 love.2016.2.20.ionic
Study4 love.2016.2.20.ionic
 
Asp.Net MVC 一教就上手
Asp.Net MVC 一教就上手Asp.Net MVC 一教就上手
Asp.Net MVC 一教就上手
 
輕鬆上手ASP.NET Web API 2.1.2
輕鬆上手ASP.NET Web API 2.1.2輕鬆上手ASP.NET Web API 2.1.2
輕鬆上手ASP.NET Web API 2.1.2
 
twMVC#05 |開發與移轉 ASP.NET MVC 4.0 應用程式到 Windows Azure Platform
twMVC#05 |開發與移轉 ASP.NET MVC 4.0 應用程式到 Windows Azure PlatformtwMVC#05 |開發與移轉 ASP.NET MVC 4.0 應用程式到 Windows Azure Platform
twMVC#05 |開發與移轉 ASP.NET MVC 4.0 應用程式到 Windows Azure Platform
 
Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4
 
Asp.net mvc 概觀介紹
Asp.net mvc 概觀介紹Asp.net mvc 概觀介紹
Asp.net mvc 概觀介紹
 
WoT Frotend 的設計與實作
WoT Frotend 的設計與實作WoT Frotend 的設計與實作
WoT Frotend 的設計與實作
 
ASP.NET MVC 善用網路資源快速完打造網站
ASP.NET MVC 善用網路資源快速完打造網站ASP.NET MVC 善用網路資源快速完打造網站
ASP.NET MVC 善用網路資源快速完打造網站
 
開發的效能與效率-twMVC#15
開發的效能與效率-twMVC#15開發的效能與效率-twMVC#15
開發的效能與效率-twMVC#15
 

Andere mochten auch (20)

Ian Lisk Resume
Ian Lisk ResumeIan Lisk Resume
Ian Lisk Resume
 
ખીલીબાઈ ની વાર્તા
ખીલીબાઈ ની વાર્તા ખીલીબાઈ ની વાર્તા
ખીલીબાઈ ની વાર્તા
 
20091120 Weekly
20091120 Weekly20091120 Weekly
20091120 Weekly
 
KoeratõUd
KoeratõUdKoeratõUd
KoeratõUd
 
vertexdb
vertexdbvertexdb
vertexdb
 
Aa zoe lacchei pinturas
Aa zoe lacchei pinturas Aa zoe lacchei pinturas
Aa zoe lacchei pinturas
 
Human Rights
Human RightsHuman Rights
Human Rights
 
Dvd轉Avi
Dvd轉AviDvd轉Avi
Dvd轉Avi
 
我的學思歷程 劉兆玄
我的學思歷程 劉兆玄我的學思歷程 劉兆玄
我的學思歷程 劉兆玄
 
看病的方法
看病的方法看病的方法
看病的方法
 
如何正確吃水果
如何正確吃水果如何正確吃水果
如何正確吃水果
 
Pythonpresent
PythonpresentPythonpresent
Pythonpresent
 
從衛星看地球奇景
從衛星看地球奇景從衛星看地球奇景
從衛星看地球奇景
 
Windows 7兼容性系列课程(5):Windows 7徽标认证
Windows 7兼容性系列课程(5):Windows 7徽标认证Windows 7兼容性系列课程(5):Windows 7徽标认证
Windows 7兼容性系列课程(5):Windows 7徽标认证
 
自己打造金湯匙
自己打造金湯匙自己打造金湯匙
自己打造金湯匙
 
蝢慰 敺 鈭 Pps
蝢慰  敺 鈭 Pps蝢慰  敺 鈭 Pps
蝢慰 敺 鈭 Pps
 
你今天的選擇是什麼?
你今天的選擇是什麼?你今天的選擇是什麼?
你今天的選擇是什麼?
 
柬埔寨鄉村婚禮
柬埔寨鄉村婚禮柬埔寨鄉村婚禮
柬埔寨鄉村婚禮
 
Asp.Net2 12
Asp.Net2 12Asp.Net2 12
Asp.Net2 12
 
呵護腎臟的方法
呵護腎臟的方法呵護腎臟的方法
呵護腎臟的方法
 

Ähnlich wie Asp.Net Mvc 1.0

Asp.net+mvc4框架揭秘
Asp.net+mvc4框架揭秘Asp.net+mvc4框架揭秘
Asp.net+mvc4框架揭秘
Zhenhua Tang
 
建站大业,实战ASP.NET 4
建站大业,实战ASP.NET 4建站大业,实战ASP.NET 4
建站大业,实战ASP.NET 4
Cat Chen
 
ASP.Net MVC2 简介
ASP.Net MVC2 简介ASP.Net MVC2 简介
ASP.Net MVC2 简介
Allen Lsy
 
Vlog02 [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
Vlog02  [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...Vlog02  [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
Vlog02 [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
SernHao TV
 

Ähnlich wie Asp.Net Mvc 1.0 (20)

twMVC#20 | ASP.NET MVC View 開發技巧小錦囊
twMVC#20 | ASP.NET MVC View 開發技巧小錦囊twMVC#20 | ASP.NET MVC View 開發技巧小錦囊
twMVC#20 | ASP.NET MVC View 開發技巧小錦囊
 
Asp.net mvc 基礎
Asp.net mvc 基礎Asp.net mvc 基礎
Asp.net mvc 基礎
 
Asp.net+mvc4框架揭秘
Asp.net+mvc4框架揭秘Asp.net+mvc4框架揭秘
Asp.net+mvc4框架揭秘
 
twMVC#10 | ASP.NET MVC Model 的設計與使用
twMVC#10 | ASP.NET MVC Model 的設計與使用twMVC#10 | ASP.NET MVC Model 的設計與使用
twMVC#10 | ASP.NET MVC Model 的設計與使用
 
twMVC#02 | ASP.NET MVC 從無到有
twMVC#02 | ASP.NET MVC 從無到有twMVC#02 | ASP.NET MVC 從無到有
twMVC#02 | ASP.NET MVC 從無到有
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVC
 
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit TestingASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
 
twMVC#03 | ASP.NET MVC 新增、查詢、修改、刪除 基本功實戰
twMVC#03 | ASP.NET MVC 新增、查詢、修改、刪除 基本功實戰twMVC#03 | ASP.NET MVC 新增、查詢、修改、刪除 基本功實戰
twMVC#03 | ASP.NET MVC 新增、查詢、修改、刪除 基本功實戰
 
輕鬆上手Asp.net web api 2.1-twMVC#14
輕鬆上手Asp.net web api 2.1-twMVC#14輕鬆上手Asp.net web api 2.1-twMVC#14
輕鬆上手Asp.net web api 2.1-twMVC#14
 
twMVC#14 | 輕鬆上手ASP.NET Web API 2
twMVC#14 | 輕鬆上手ASP.NET Web API 2twMVC#14 | 輕鬆上手ASP.NET Web API 2
twMVC#14 | 輕鬆上手ASP.NET Web API 2
 
ASP.NET MVC (Gi Days)
ASP.NET MVC (Gi Days)ASP.NET MVC (Gi Days)
ASP.NET MVC (Gi Days)
 
建站大业,实战ASP.NET 4
建站大业,实战ASP.NET 4建站大业,实战ASP.NET 4
建站大业,实战ASP.NET 4
 
Single-Page Application Design Principles 101
Single-Page Application Design Principles 101Single-Page Application Design Principles 101
Single-Page Application Design Principles 101
 
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
 
MVC MVVM MVVMC
MVC MVVM MVVMCMVC MVVM MVVMC
MVC MVVM MVVMC
 
ASP.NET MVC The Begining
ASP.NET MVC The BeginingASP.NET MVC The Begining
ASP.NET MVC The Begining
 
ASP.Net MVC2 简介
ASP.Net MVC2 简介ASP.Net MVC2 简介
ASP.Net MVC2 简介
 
Vlog02 [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
Vlog02  [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...Vlog02  [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
Vlog02 [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
 
Non-MVC Web Framework
Non-MVC Web FrameworkNon-MVC Web Framework
Non-MVC Web Framework
 
ASP.NET MVC简介
ASP.NET MVC简介ASP.NET MVC简介
ASP.NET MVC简介
 

Mehr von Chui-Wen Chiu

Mehr von Chui-Wen Chiu (20)

Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
Introduce Django
Introduce DjangoIntroduce Django
Introduce Django
 
移動內存算法
移動內存算法移動內存算法
移動內存算法
 
墾丁 更新版
墾丁  更新版墾丁  更新版
墾丁 更新版
 
墾丁 更新版2
墾丁  更新版2墾丁  更新版2
墾丁 更新版2
 
Bw1096
Bw1096Bw1096
Bw1096
 
高雄新地標 統一夢世代
高雄新地標  統一夢世代高雄新地標  統一夢世代
高雄新地標 統一夢世代
 
Borland傳奇
Borland傳奇Borland傳奇
Borland傳奇
 
Python 庫簡介
Python 庫簡介Python 庫簡介
Python 庫簡介
 
天下第一 夜市總冠軍
天下第一 夜市總冠軍天下第一 夜市總冠軍
天下第一 夜市總冠軍
 
下班就跑是富有哲學道理1
下班就跑是富有哲學道理1下班就跑是富有哲學道理1
下班就跑是富有哲學道理1
 
認識腸病毒
認識腸病毒認識腸病毒
認識腸病毒
 
排隊的店
排隊的店排隊的店
排隊的店
 
新 創 意
新 創 意新 創 意
新 創 意
 
挖好屬於自己的井
挖好屬於自己的井挖好屬於自己的井
挖好屬於自己的井
 
Why The Us Wants War 080702
Why The Us Wants War  080702Why The Us Wants War  080702
Why The Us Wants War 080702
 
Unknown Parameter Value
Unknown Parameter ValueUnknown Parameter Value
Unknown Parameter Value
 
你也在井裡嗎
你也在井裡嗎你也在井裡嗎
你也在井裡嗎
 
世界是平的
世界是平的世界是平的
世界是平的
 
感觸
感觸感觸
感觸
 

Asp.Net Mvc 1.0

  • 1. 利用 ASP.NET MVC 提升您的 Web 應用程式 董大偉 David@studyhost.com 台灣微軟MSDN講座講師 TechED 2007, 2008講師
  • 2. Develop Web Application with ASP.NET MVC 本場次大綱 從5W1H看ASP.NET MVC 什麼是MVC? 透過這樣的架構開發的應用程式有何優點? ASP.NET MVC Framework又是什麼? 和ASP.NET WebForm技術不同嗎? 如何利用ASP.NET MVC來開發MVC應用程式? 如何撰寫出較好的Web應用程式?
  • 3. 解決方案總是從問題而來 - Develop Web Application with ASP.NET MVC ASP.NET MVC的 5W 1H WHAT - 什麼是ASP.NET MVC? WHEN - 何時需要使用ASP.NET MVC? WHY - 為何要使用ASP.NET MVC? WHO - 誰適合來使用ASP.NET MVC? WHERE - 在些場合中需要使用ASP.NET MVC? HOW - 如何開發ASP.NET MVC 應用程式?
  • 4. 什麼是MVC? - Develop Web Application with ASP.NET MVC MVC… 是一種設計模式。 MVC這個Pattern要求我們在開發程式的時候,把我們要透過 程式碼達成的一個功能,在設計時切割成Model、View、 Controller這三個部分(的程式碼)。 每一個部分可以獨立互不干涉,但執行時可以互相合作,已 達成功能,開發時亦可由不同的開發人員進行開發、同時也 便於Unit Test。 目的: 降低程式碼之間的相依性、提高重用性 便於多人開發、單元測試、降低開發成本 結構清晰、利於後續維護 …
  • 5. 什麼是MVC? - Develop Web Application with ASP.NET MVC Controller Model View
  • 6. 什麼是MVC? - Develop Web Application with ASP.NET MVC ASP.NET MVC 微軟平台上新提供的MVC開發架構,透過這組 類別庫,開發人員可以MVC架構來建立Web應 用程式。這組MVC架構可以同時提高程式的延 展性與彈性,降低.aspx頁面與後端資料庫、商 業邏輯之間的相依性,達成大型專案的快速開 發、高重用性、容易調整與維護的目的。
  • 7. 什麼是ASP.NET MVC Framework - Develop Web Application with ASP.NET MVC ASP.NET MVC Framework是… 架構在ASP.NET技術上的一組Framework。 讓開發人員得以輕鬆建立出MVC架構的應用程式。 提供建構MVC應用程式所需的基礎類別、以及相關工具 (Helper) 。 概念上與ASP.NET WebForm並不相同,不支援事件驅動、 Web Controls、或是Postback…等機制。 支援了一些ASP.NET過去相當優秀的設計,例如Master- Page、MemberShip、UserControl等機制。
  • 8. ASP.NET MVC Framework • 負責與UI顯示有關的部分,在這個部分當中的程式碼,只應該與 UI(或UI上的操作)有關,不應該有任何與商業邏輯、後端資料庫有 關的任何程式碼,對於Web應用程式來說,就是Render出HTML 與前端JavaScript操作的部分。 View • 這個部分的程式碼可以是部分的商業邏輯、可以是應用程式當中 所需要的運算規則或演算法、Controller中的程式碼可以依照實際 的需求(功能)決定調用(或存取)哪一個Model、可以動態的決定用 哪一個View來呈現運算後的結果,Controller同時也負責回應前端 View所產生的事件(或需求)。 Controller • 一般來說就是Data Model,同時負責了實際資料庫存取的部分, 這部分的程式碼負責把後端資料庫給封裝起來,讓Controller或 View可以完全不(需要)知道(或不在乎)後端資料庫的長相究竟為何, 只需要透過Model即可正確的存取後端資料庫。 Model
  • 10. Protected Sub Button_GetBMI_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button_GetBMI.Click Dim BMI As Single Dim height, weight As Single '從UI取得身高體重 height = Me.TextBox_Height.Text weight = Me.TextBox_Weight.Text '計算BMI(主要邏輯運算) BMI = weight / (height / 100) ^ 2 '顯示BMI Me.Label_Result.Text = "計算結果 BMI=" & BMI ‘將資料儲存到資料庫 SqlDataSource1.InsertCommand = "Insert into BmiData (Height,Weight,BMI) values (@Height,@Weight,@BMI)" SqlDataSource1.InsertParameters.Add("Height", height) SqlDataSource1.InsertParameters.Add("Weight", weight) SqlDataSource1.InsertParameters.Add("BMI", BMI) '顯示訊息 If SqlDataSource1.Insert() > 0 Then ClientScript.RegisterStartupScript(Me.GetType, "", "alert('儲存成功');", True) Else ClientScript.RegisterStartupScript(Me.GetType, "", "alert('儲存失敗');", True) End If 『一氣呵成』、從前端殺到後端的『直搗狂龍式』寫法ClassicBmiWebAP MVC三合一應用程式  這種程式我們稱為:MVC三合一寫法
  • 11. MVC三合一的問題 - Develop Web Application with ASP.NET MVC 在同一個事件當中, 又處理UI, 又處理邏輯, 又存 取DB 前端.aspx頁面與後端資料庫密不可分 前端.aspx頁面與後端商業邏輯程式碼難分難捨 即使具有DataAccess Class也難免保證開發人員 遵循(*) 牽一髮而動全身
  • 12. MVC三合一的問題 - Develop Web Application with ASP.NET MVC 應該如何改進? 1. 將Business Logic獨立出來 2. 將資料庫存取部分獨立出來 結果: 1. 程式碼相依性降低、可重用性提高 2. 程式碼變多? 3. 效能會提升嗎?
  • 13. DEMO:調整MVC三合一程式,使之  將Business Logic獨立出來  將資料庫存取部分獨立出來  程式碼相依性降低、可重用性提高 D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCClassicBmiWebAP2
  • 14. MVC的目的 - Develop Web Application with ASP.NET MVC 避免在同一段程式碼當中, 又處理UI, 又處理邏輯, 又存取DB… 降低程式之間的相依性、提高重用性 讓程式碼結構更加清晰 不同的模塊可由擅長該技術的專職開發人員進行 開發,降低開發成本,提高產能 便於Unit Test、使TDD成為可能
  • 15. DEMO:建構第一個MVC應用程式  建立ASP.NET MVC Web Application  建立BMI Controller與Index Action  建立ViewPage(含欄位)  撰寫BMI Class  在Controller中接收參數 調用BMI Class, 輸出結果 D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCBmiMvcApp
  • 17. 認識Controller - Develop Web Application with ASP.NET MVC 負 責 接 收 Browser 端 透 過 HTTP GET/POST 傳 來 的 Request Url可決定該Request由哪一個Controller、哪一個 Action來負責 Controller當中可以進行各種運算、亦可能包含商業邏 輯、各種演算法…等程式碼。 如果有需要,可調用Model來進行後端資料庫存取的 動作。 最後決定由哪一個View來處理結果的呈現。 同時將View需要呈現的資料透過ViewData傳遞給 View。
  • 18. 關於URL Routing - Develop Web Application with ASP.NET MVC URL Routing機制負責將Browser傳來的Request對應 到Controller與Action。 在這種設計架構下,我們可以用同一個『頁面』負責 同一種『工作』 。 可降低頁面的數量,每一個頁面(View)清楚的負責一 種『功能』,不需要撰寫許多頁面負責同樣的功能(例 如不同資料表的顯示)。 URL直接對應到『功能』 ,在邏輯上更加直覺。 http://localhost:50302/bmi/index Web Site Controller Action
  • 19. 認識Controller - Develop Web Application with ASP.NET MVC Controller中程式碼的撰寫方式, 同名處理不同的Verbs ' HTTP GET: /Bmi/Index Function Index() As ActionResult (…略…) Return View() End Function ' HTTP POST: /Bmi/Index <AcceptVerbs(HttpVerbs.Post)> _ Function Index(ByVal TxbHeight As Single, ByVal TxbWeight As Single) As ActionResult (…略…) Return View() End Function 使用預設的View(也就是 BMI/Index.aspx)來回應 從View欄位接收參數
  • 20. 關於URL Routing - Develop Web Application with ASP.NET MVC 例如,底下的URL可以用來顯示編號為17的產品: 請注意Global.asax檔案(設定Url Route, 底下為預設) http://store.abc.com/product/ShowDetails/17 Web Site Controller Action ID routes.MapRoute( _ "Default", _ "{controller}/{action}/{id}", _ New With {.controller = "Home", .action = "Index", .id = ""} _ )
  • 21. 認識Controller - Develop Web Application with ASP.NET MVC Controller中程式碼的撰寫方式 各種ActionResult ViewResult, EmptyResult, RedirectResult, JavaScriptResult, ContentResult, FileContentResult, FilePathresult, FileStreamResult, … ' GET: /product/ShowDetails Function ShowDetails(ID As Integer) As ActionResult '取得ID '透過Data Model抓取資料庫中的內容 ‘將資料傳遞給ViewPage Return View() End Function
  • 22. Controller如何與View溝通? - Develop Web Application with ASP.NET MVC 抓取ViewPage上的欄位值 ' POST: /Bmi/Index <AcceptVerbs(HttpVerbs.Post)> _ Function Index(ByVal TxbHeight As Single, ByVal TxbWeight As Single) As ActionResult (…略…) '使用預設的VIew Return View() End Function
  • 23. Controller如何與View溝通? - Develop Web Application with ASP.NET MVC 透過ViewData將資料傳給ViewPage ' POST: /Bmi/Index <AcceptVerbs(HttpVerbs.Post)> _ Function Index(ByVal TxbHeight As Single, ByVal TxbWeight As Single) As ActionResult Dim BMI As Single Dim MyBMI As New BMI '使用BMI類別進行運算 MyBMI.Height = TxbHeight MyBMI.Weight = TxbWeight BMI = MyBMI.GetBMI() '將執行結果傳遞給View ViewData("result") = BMI '使用預設的VIew Return View() End Function
  • 24. Controller如何與View溝通? - Develop Web Application with ASP.NET MVC 透過ViewData將資料傳給ViewPage ' POST: /Bmi/Index <AcceptVerbs(HttpVerbs.Post)> _ Function Index(ByVal TxbHeight As Single, ByVal TxbWeight As Single) As ActionResult (…略…) Return View(Model) End Function 可傳遞任何的物件給 ViewPage
  • 25. 認識Controller - Develop Web Application with ASP.NET MVC 建立在Controllers資料夾中 繼承自System.Web.Mvc.Controller 負責回應Browser的各種Request 如何從ViewPage接收參數? 透過ID、透過ViewPage上的欄位 如何傳遞參數給ViewPage? 透過ViewData、透過ViewResult的Model參數
  • 26. 認識ViewPage - Develop Web Application with ASP.NET MVC 負責展示層UI的顯示。 與商業邏輯運算、後端資料庫均無關。 在這個部分當中可以有程式碼,但程式碼只應該與UI(或 UI上的操作)有關,不應該有任何與商業邏輯、後端資料 庫有關的任何程式碼,對於Web應用程式來說,主要就 是Render出HTML與前端JavaScript操作的部分。 繼承於System.Web.Mvc.ViewPage 。 可透過ViewData取得來自Controller的資料。 可透過Model取得來自Controller的複雜資料。 具有HtmlHelper可使用,便於開發。
  • 27. 認識ViewPage - Develop Web Application with ASP.NET MVC 與過去ASP類似的程式撰寫方式 可透過HTML Helper協助產生需要的Html Element 不支援Web Controls 可透過ViewData抓取到Controller傳遞過來的資料 <% Using Html.BeginForm() %> <br/>身高:<% =Html.TextBox("TxbHeight") %> <br/>體重:<% =Html.TextBox("TxbWeight") %> <input type="submit" value="Calculate" /> <% End Using%> <% If ViewData("result") IsNot Nothing Then Response.Write("BMI:" & ViewData("result")) %>
  • 28. 認識ViewPage - Develop Web Application with ASP.NET MVC Html Helper支援… Html.ActionLink(linkText,ActionName,ControllerName) Html.TextBox(name) Html.TextArea(name) Html.RadioButton(name,value) Html.BeginForm() Html.Encode(value) …
  • 29. DEMO:將MVC應用程式加入資料庫存取  使用先前的BmiMvcApp  加入資料庫  調整ViewPage(新增欄位)  加入LinqToSql Data Model(封裝資料庫) D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCBmiMvcAppWithDB
  • 30. 認識Model - Develop Web Application with ASP.NET MVC 負責了實際資料庫存取的部分。 這部分的程式碼負責把後端資料庫給封裝起來,讓 Controller或View可以完全不(需要)知道(或不在乎)後端 資料庫的長相究竟為何,只需要透過Model即可正確的 存取後端資料庫。 有效的隔離展示層程式碼與後端資料庫 可透過Bind修飾字將ViewPage上的資料繫結到 Controller的參數,以便於儲存到DB Contoller中可透過ViewResult的Model參數將從DB取得 的資料以物件型態傳遞給ViewPage。(請注意ViewPage 須設定泛型型別)
  • 31. 認識Model - Develop Web Application with ASP.NET MVC Contoller中可透過ViewResult的Model參數將從DB取得 的資料,以物件型態傳遞給ViewPage。(請注意 ViewPage須設定泛型型別) Dim db As New AddressBookDBDataContext ' ' HTTP GET: /AddressBook/ Function Index() As ActionResult Return View(db.AddressBook.ToList) End Function
  • 32. 認識Model - Develop Web Application with ASP.NET MVC 承接的ViewPage,需要設定泛型型別,以便於取得資料 <%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(Of IEnumerable (Of AddressBookMvcApp.AddressBook))" %> <% For Each item In Model%> <tr> <td> <%=Html.ActionLink("Edit", "Edit", New With {.id = item.uid})%> | <%=Html.ActionLink("Details", "Details", New With {.id = item.uid})%> </td> <td> <%= Html.Encode(item.uid) %> </td> <td> <%= Html.Encode(item.cName) %> </td> <td> <%= Html.Encode(item.cTel) %> </td> <td> <%= Html.Encode(item.cMemo) %> </td> </tr> <% Next%> </table> </asp:Content>
  • 33. 認識Model - Develop Web Application with ASP.NET MVC 儲存(回寫)資料時,亦可透過Bind修飾字將ViewPage上 的資料繫結到Controller的參數,以便於儲存到DB。 'Post: /Home/Create <AcceptVerbs(HttpVerbs.Post)> _ Function Create(<Bind(exclude:="uid")> ByVal TableData As AddressBookMvcApp.AddressBook) As ActionResult db.AddressBook.InsertOnSubmit(TableData) db.SubmitChanges() Return RedirectToAction("Index") End Function
  • 34. DEMO:建立資料庫處理MVC應用程式  AddressBookMvcApp  加入資料庫AddressBookDB.mdf  建立Data Model  建立並規劃AddressBook Controller  Index – 顯示所有紀錄  Create– 建立資料  建立相對應的ViewPage(可用Wizard)  撰寫Controller程式碼 D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCAddressBookMvcApp
  • 35. 關於Unit Test - Develop Web Application with ASP.NET MVC 由於View與Business Logic已經切割開來, 有助於Unit Test的進行。 D:MyDoc0T.教育訓練Microsoft MSDN講座-ASP.NET MVCBmiMvcApp <TestMethod()> Public Sub TestMethod1() Dim theBmiController As New BmiController Dim theViewResult As ViewResult = theBmiController.Index(170, 70) Assert.AreEqual("24.22145", theViewResult.ViewData("result").ToString) End Sub
  • 36. 解決方案總是從問題而來 - Develop Web Application with ASP.NET MVC ASP.NET MVC的 5W 1H WHAT - 什麼是ASP.NET MVC? WHEN - 何時需要使用ASP.NET MVC? WHY - 為何要使用ASP.NET MVC? WHO - 誰適合來使用ASP.NET MVC? WHERE - 在些場合中需要使用ASP.NET MVC? HOW - 如何開發ASP.NET MVC 應用程式?
  • 38. ASP.NET MVC相關資源 筆者 BLOG http://blog.studyhost.com/ 筆者 RUN!PC ASP.NET 3.5 SP1-4.0專欄 ASP.NET網站MVC篇: http://www.asp.net/mvc/
  • 39. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Hinweis der Redaktion

  1. 1/30/2015 3:29 PM
  2. 1/30/2015 3:29 PM
  3. 1/30/2015 3:29 PM
  4. 1/30/2015 3:29 PM
  5. 1/30/2015 3:29 PM
  6. 降低相依性, 不能假設View知道Controller, 或Contoller知道View, 僅依照ViewData交換資料, Contoller可以決定用哪一個View或Model…
  7. 降低相依性, 不能假設View知道Controller, 或Contoller知道View, 僅依照ViewData交換資料, Contoller可以決定用哪一個View或Model…
  8. 1/30/2015 3:29 PM
  9. 1/30/2015 3:29 PM
  10. 1/30/2015 3:29 PM
  11. 1/30/2015 3:29 PM
  12. 1/30/2015 3:29 PM
  13. 1/30/2015 3:29 PM
  14. 1/30/2015 3:29 PM
  15. 1/30/2015 3:29 PM
  16. 1/30/2015 3:29 PM
  17. 1/30/2015 3:29 PM
  18. 1/30/2015 3:29 PM
  19. 1/30/2015 3:29 PM
  20. 1/30/2015 3:29 PM
  21. 1/30/2015 3:29 PM
  22. 1/30/2015 3:29 PM
  23. 1/30/2015 3:29 PM
  24. 1/30/2015 3:29 PM
  25. 1/30/2015 3:29 PM
  26. 1/30/2015 3:29 PM
  27. 1/30/2015 3:29 PM
  28. 1/30/2015 3:29 PM
  29. 1/30/2015 3:29 PM
  30. 1/30/2015 3:29 PM
  31. 1/30/2015 3:29 PM
  32. 1/30/2015 3:29 PM
  33. 1/30/2015 3:29 PM
  34. 1/30/2015 3:29 PM
  35. 1/30/2015 3:29 PM