Categories

Aug 18, 2019 in MVC Language

Q: Mention three ways to pass data between the controllers and views, and when to use each of them?

1 Answer

Aug 18, 2019

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.

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Aug 18, 2019 in MVC Language
Aug 18, 2019 in MVC Language
Aug 18, 2019 in MVC Language
...