---
title: "What are the various ways to send data from a controller to view?"  
description: "What are the various ways to send data from a controller to view?"  
author: "Manish Kumar"  
published: 2017-05-31  
updated: 2020-09-23  
canonical: https://www.mindstick.com/interview/23257/what-are-the-various-ways-to-send-data-from-a-controller-to-view  
category: "c#"  
tags: ["c#", "mvc4"]  
reading_time: 2 minutes  

---

# What are the various ways to send data from a controller to view?

**ViewBag:** It is a dynamic property.

**Controller::** ViewBag.Name = “Mindstick”;

**View::** @ViewBag.Name

**ViewData:** It is a Dictionary object derived from the ViewDataDictionary class. It requires type casting and null check for complex data types.

**Controller:**: ViewData[“Name”] = “Mindstick”;

**View::** @ViewData[“Name”]

ViewBag and ViewData spans for a server call.

**TempData:** It is a dictionary derived from the TempDataDictionary class. It stores data in a short live session and spans for a HTTP request. It is used when moving from a controller to another or from an action method to another. It is for the current and subsequent request only. It requires type casting and null check for complex data types.

## Answers

### Answer by Manish Kumar

**ViewBag:** It is a dynamic property.

**Controller::** ViewBag.Name = “Mindstick”;

**View::** @ViewBag.Name

**ViewData:** It is a Dictionary object derived from the ViewDataDictionary class. It requires type casting and null check for complex data types.

**Controller:**: ViewData[“Name”] = “Mindstick”;

**View::** @ViewData[“Name”]

ViewBag and ViewData spans for a server call.

**TempData:** It is a dictionary derived from the TempDataDictionary class. It stores data in a short live session and spans for a HTTP request. It is used when moving from a controller to another or from an action method to another. It is for the current and subsequent request only. It requires type casting and null check for complex data types.


---

Original Source: https://www.mindstick.com/interview/23257/what-are-the-various-ways-to-send-data-from-a-controller-to-view

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
