使用 Visual Studio 2008 建立「ASP.NET MVC Web 應用程式」專案,預設會產生兩個專案:主 Web 專案與測試專案。測試專案支援 MSTest、NUnit、MBUnit 等框架,方便實踐測試驅動開發 (TDD)。
本範例實作三個核心 URL:
/Products/Categories - 瀏覽所有產品分類/Products/List/{CategoryName} - 列出指定分類的產品/Products/Detail/{ProductID} - 顯示產品詳細資訊透過 ProductsController 處理請求,View 呈現資料,Model 封裝業務邏輯,展現關注點分離優勢。