> For the complete documentation index, see [llms.txt](https://jen-hsuan-hsieh.gitbook.io/asp-net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jen-hsuan-hsieh.gitbook.io/asp-net/chapter1/12the-note-of-asp-net-mvc/121net-mvc-overview-and-razor-view.md).

# 1.2.1..NET MVC overview and razor view

* Controller傳遞資料給View的方式
  * ViewData
    * 引用System.Web.Mvc.ViewDataDictionary
    * Dictionary, 存放資料的方式為key/ value, 可在Controller與View之間傳遞
    * 生命週期只有一個action
  * ViewBag
    * 引用System.Web.Mvc.ControllerBase.ViewBag
    * 用法與ViewData相似, 不同的是型別是dynamic object (動態物件)
  * TempData
    * 引用System.Web.Mvc.TempDataDictionary&#x20;
    * Dictionary, 存放資料的方式為key/ value
    * 與ViewData的生命周期不同, 可以跨一個request
