Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic TempData in ASP.NET MVC 3

I'vm been trying to get a site running using ASP.NET MVC 3 and I came across the new dynamic ViewModel. It's great to pass values quickly to the view without using "magic strings". I'm wondering if there's something similar for the TempData that keeps it's values after a RedirectToAction.

Thanks.

like image 276
Carles Company Avatar asked Nov 30 '25 17:11

Carles Company


1 Answers

TempData is not dynamic in MVC 3 (as long as I can tell anyway) e.g. this syntax does not compile :

TempData.Account = "Geronimo"

because Account property/field does not exists on the type.

ViewBag Is dynamic

ViewBag.Acount = "Geronimo" 

compiles.

like image 122
Olivier B Avatar answered Dec 02 '25 09:12

Olivier B