+1 vote
in MVC Language by
Mention three ways to pass data between the controllers and views, and when to use each of them?

1 Answer

0 votes
by

ViewData: It is available for the current request only and requires typecasting for complex data type.

ViewBag: Dynamic property that takes advantage of the new dynamic features in C# 4.0, also available for the current request only. If redirection occurs, then its value becomes null and doesn’t require typecasting for complex data type.

TempData: used to pass data from the current request to the next request, keeps the information for the time of an HTTP Request. This means only from one page to another.

Related questions

0 votes
asked Aug 18, 2019 in MVC Language by rahulsharma
0 votes
asked Aug 18, 2019 in MVC Language by rahulsharma
...