ViewData
public ViewDataDictionary ViewData { get; set; }
graph LR
subgraph ViewData
A>Live only Current Request]
B>TypeChecking May Required]
Controller-->A
A-->B
B-->View
style A stroke:#ccc,stroke-width:2px,stroke-dasharray: 2, 1;
style B stroke:#f00,stroke-width:2px,stroke-dasharray: 2, 1;
end
ViewBag
public Object ViewBag { get; }
graph LR
subgraph ViewBag
A>Live only Current Request]
B>TypeChecking May Not Required]
Controller-->A
A-->B
B-->View
style A stroke:#ccc,stroke-width:2px,stroke-dasharray: 2, 1;
style B stroke:#0c0,stroke-width:2px,stroke-dasharray: 2, 1;
end
- It is Wrapper around the ViewData.
TempData
public TempDataDictionary TempData { get; set; }
graph LR
subgraph TempData
A>Short Life]
B>TypeChecking May Required]
PV[Parent View]-->A
A-->B
B-->V[View]
style A stroke:#ccc,stroke-width:2px,stroke-dasharray: 2, 1;
style B stroke:#f00,stroke-width:2px,stroke-dasharray: 2, 1;
end
- Store one time messages like error messages, validation messages.
Session
public HttpSessionStateBase Session { get; }
graph LR
subgraph Session
A>Live for 20 Min Default]
B>TypeChecking May Required]
PV[Parent View or Controller]---A
A---B
B---V[Child View or Controller]
style A stroke:#ccc,stroke-width:2px,stroke-dasharray: 2, 1;
style B stroke:#f00,stroke-width:2px,stroke-dasharray: 2, 1;
end