ASP.
NETMVC實戰經驗分享
多奇數位創意有限公司技術總監WILL保哥
何謂「實戰經驗」?
弄砸了4個網站以上因為玩Preview,Beta,RC而重構5次以上寫出有Bug的程式20次以上
寫過至少50個Controller
寫過至少200個Action套過至少200個View有網站同時線上人數達3,000人有網站每日上線人數達30,000人次
ASP.NETMVC開發經驗一年
有什麼實戰經驗可分享?
快速上手、學習方法協同開發、團隊分工高效能的ASP.NETMVC網站高執行效能高開發效率安全的ASP.NETMVC網站單元測試的經驗分享開發人員應注意的事常見問題解答
QATime
ASP.NETWebForm與ASP.NETMVC的差異
ASP.NETWebForm與ASP.NETMVC的差異
支援功能ViewStateASP.NET頁面追蹤機制(PageTrace)ASP.NET事件驅動模型(EventModel)伺服器控制項(ServerControl)System.Web.SiteMapProvider類別ASP.NETProviderModelSystem.Web.Caching命名空間System.Web.SessionState命名空間System.Web.Security命名空間Profile,Membership,SiteMap其他System.Web.*功能ASP.NETWebFormASP.NETMVC1.0/2.0部分支援
ASP.NETWebForm與ASP.NETMVC的差異
相同之處都是IHttpHandler的產物共享ASP.NETFramework的所有功能IL指令集差很多System.Web.Mvc.*:16,902ILinstructions
雖然ASP.NETMVC的WebFormView用到許多原本WebForm的東西,但是還是很多控制項不會去用他!ASP.NETMVC的ViewPage繼承System.Web.UI.Page(非常邪惡)
System.Web.UI.*:238,179ILinstructions
快速上手、學習方法
簡化版的ASP.NETMVC執行生命週期
HTTP要求Controller
GET/Product/Detail/1
ProductController.Detail(1)
ModelView
HTTP回應
ProductRepository.GetProduct(1)
~/Views/Product/Detail.aspx
HTML,XML,RSS,Text,
CSS,File(Binary),…
簡化版的ASP.NETMVC執行生命週期
HTTP要求Controller
POST/Product/Edit/1
ProductController.Edit(1,FormCollectionc)TryUpdateModel(product,newstring[]{“Name"})
ModelView
HTTP回應
varproduct=ProductRepository.GetProduct(1)ProductRepository.UpdateProduct(1,product)
N/A
HTTP重導向(Redirection)
瞭解ASP.NETMVC執行生命週期
Request
ControllerFactory
Controller
URLRouting
HttpHandler
ViewFactory
Route
RouteHandler