Mid
From PDF
ASP.NET Core
ASP.NET Core
ViewData, ViewBag, TempData: differences and uses Type Lifetime Dynami c?
Short answer: Purpose ViewDa ta Current request No Pass data to views ViewBa Current request Yes ViewData wrapper (dynamic) TempD ata Across requests No Preserved for 1 redirect only
Real-world example (ShopNest)
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png