Is it possible to retain ViewBag value from one to another page in MVC?
I want to pass ViewBag value from one page to another. Currently, When I move to another page, the value is getting lost. Can anyone please suggest me how to retain the value after page reloads.
This piece of code is inside Home Controller and also added into its Index Page. But when I move to another page, the value is getting lost.
ViewBag.CounryName = "USA";
you can refer following post. TempData keep() vs peek(). If you still have problem then you can use Session instead of viewbag.