1

In Asp.net there are 2 types of State management technique

Server Side State management

  1. Session
  2. Application State
  3. Profile

Client Side state management

  1. ViewState
  2. QueryString
  3. Cookies
  4. Control State
  5. Hidden Fields

I know that in Asp.net MVC above all state supported except ViewState and Control State.

I'm confused over ViewData, ViewBag, TempData in which category they belongs like Client Side State management technique or Server Side state management technique.

I mean if we store data in ViewData, ViewBag or TempData then where they holds memory space at Client machine or Server machine.

Sandeep
  • 21
  • 5
  • 2
    All 3 are server side. Refer also [ViewBag, ViewData and TempData](https://stackoverflow.com/questions/7993263/viewbag-viewdata-and-tempdata) –  Nov 22 '18 at 06:43
  • Hi Stephen Muecke are you sure because i'm not getting any confident answer i have serched lot of article. I confused because reading this article https://biswaranjan2010.wordpress.com/state-management-techniques-in-asp-net-mvc/ – Sandeep Nov 22 '18 at 07:11
  • Read the link gave you (or hundreds of others that explain what `ViewData`, `ViewBag` and `TempData` are). None of them have anything to do with client Side state management, and only `TempData` relates to server Side State management (it uses `Session`) –  Nov 22 '18 at 07:15

1 Answers1

1

ViewData, ViewBag and TempData are all stored on the server. Use TempData when you want to send something from one action to another action method. Use ViewBag and ViewData when you want to send data from an Action method to a view.

Also the best approach is to simply use ViewModels

Fakhar Ahmad Rasul
  • 1,595
  • 1
  • 19
  • 37