View Bag- View Bag is use to pass data from controller to view not vice versa . it is valid only at the current request only. If redirection occurs its value will be null. It doesn’t require typecasting. View Bag is the dynamic property of ControllerBase class. View Data – View Data is use to pass data from controller to view in the current request only but not vice versa. It uses string as key. If redirection occurs it value will be null. It requires Typecasting. Temp data- Temp data is use to pass data from one action to another of the same or different controller. It retains the value after redirection.
View Bag-
View Bag is use to pass data from controller to view not vice versa . it is valid only at the current request only.
If redirection occurs its value will be null.
It doesn’t require typecasting.
View Bag is the dynamic property of ControllerBase class.
View Data –
View Data is use to pass data from controller to view in the current request only but not vice versa.
It uses string as key.
If redirection occurs it value will be null.
It requires Typecasting.
Temp data-
Temp data is use to pass data from one action to another of the same or different controller.
It retains the value after redirection.