In this article I will explain with an example, how use TempData in View in ASP.Net MVC Razor.
This article will illustrate how to display (render) the value of TempData object in View using Razor Syntax in ASP.Net MVC Razor.
Using TempData in View
In the below example, a string value is set in the TempData object in Controller and it is then displayed in View.
public class HomeController : Controller
    // GET: Home
    public ActionResult Index()
        TempData["Message"] = "Hello MVC!";
        return View();
    <meta name="viewport" content="width=device-width"/>
ASP.Net MVC: Using TempData in View