Deploy self-contained trimmed builds for smaller binaries. Example for build optimization: dotnet publish -c Release /p:PublishTrimmed=true /p:ReadyToRun=true 🔐 10. What is Data Protection in ASP.NET Core? Follow :
Short answer: ASP.NET Core Data Protection API provides secure cryptographic APIs for: Encrypting cookies and tokens Protecting form data Persisting secure keys (across app restarts) Setup: builder.Services.AddDataProtection() .PersistKeysToFileSystem(new DirectoryInfo(@"c:\keys")) .SetApplicationName("MyApp"); You can use it directly: var protector =………… _provider.CreateProtector("MyPurpose"); var encrypted =…
Explain a bit more
protector.Protect("secret-data"); var decrypted = protector.Unprotect(encrypted); ✅ Data Protection is the backbone for: Cookie Authentication CSRF Tokens TempData encryption 🧠 Summary Concept Description Best For In-memory caching Stores data in server memory Single-server or dev Distributed caching Shared cache (Redis, SQL) Scalable apps Response caching Caches HTTP responses Public/static data Follow : Output caching (.NET 8) Advanced, user-aware caching Dynamic APIs Response compression Gzip/Brotli for responses Large payloads Async/await Non-blocking I/O High concurrency Startup optimization Faster app boot… ASP.NET Core Data……
Real-world example (ShopNest)
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
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