MVC學習筆記(一) 建立一個屬於自己的MVC專案
阿新 • • 發佈:2019-02-06
學習MVC兩個來月了,終於決定最個能讓自己滿意的MVC.於是,在cnblog的洞庭夕照大大的MVC5網站開發實踐的幫助下,開始了MVC之路
再次感謝洞庭夕照大大,框架就直接按洞庭夕照大大的來了..
專案名字就叫FantasyCMS好了.取自FINAL FANTASY遊戲
首先建立專案
直接選MVC,不建立EMPTY是方便新增一些必要的引用.
新增類庫
BLL,IBLL,IDAL,DAL不解釋,參考洞庭夕照大大的部落格.
反正要做,乾脆把controllers也分離出來,extensions放一些擴充套件,比如bundle,淘寶介面等.
新增引用:
Web:
IDAL:FantasyCMS.Model
IBLL:FantasyCMS.Model
DAL:
Controllers
BLL:
Extensions:
刪除Fantasy.CMS.Web內的Models,Controllers等資料夾,僅保留以下
同時把App_Start下的BundleConfig,FilterConfig,RouteConfig複製到Extensions內
同時修改這3個檔案的namespace FantasyCMS.Extensions
修改Global.asax
using System; using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; using FantasyCMS.Extensions; namespace FantasyCMS.Web { public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); } } }
OK,這樣FantasyCMS就初步完成了..
DAL,BLL的內容請參考洞庭夕照大大的部落格
再次感謝洞庭夕照大大