TempData is a Dictionary object derived from the TempDataDictionary class.
Both ViewData and ViewBag are used to pass data from a controller to a view.
ViewBag is also used to transfer data from a controller to a view.
ViewData passes data from a controller to a view.
In this blog you can get the complete source code of How To Upload And Retrieve Images using SQL Server Database In ASP.Net MVC Application.