1. DI in ASP.NET Core primarily helps with

A) Performance
B) Loose coupling & testability ✅
C) UI rendering
D) Deployment

2. Which lifetime creates a new instance per HTTP request?

A) Singleton
B) Scoped ✅
C) Transient
D) ThreadStatic

3. Which DI lifetime should DbContext use?

A) Singleton
B) Scoped ✅
C) Transient
D) Static

4. If a Singleton depends on a Scoped service, what can happen?

A) Faster execution
B) Memory leak ✅
C) Thread lock
D) No effect

5. Where are services registered in .NET Core?

A) Web.config
B) Program.cs ✅
C) AppSettings.json
D) StartupController.cs

Middleware MCQs

6. Middleware executes in:

A) Random order
B) Fixed pipeline sequence ✅
C) Compiler decides
D) Based on thread pool

7. Which method MUST be called in custom middleware?

A) Task.Run
B) builder.Build
C) await next() ✅
D) UseMvc

8. Which is used to add routing?

A) app.UseAuthorization()
B) app.UseRouting() ✅
C) app.UseEndpoints()
D) app.MapControllers()

9. Middleware that runs FIRST for error handling?

A) UseAuthorization
B) UseExceptionHandler ✅
C) UseCors
D) MapEndpoints

10. Real order in ASP.NET Core pipeline?

A)

Code
Auth → Routing → Exception

B)

Code
Exception → Routing → Auth ✅ → Endpoint

C)

Code
Endpoint → Auth → Exception

D)

Code
Auth → Endpoint → Routing

Memory & Performance MCQs

11. What causes memory leaks in .NET Core most commonly?

A) No GC
B) Event handlers not unsubscribed ✅
C) Exception handling
D) Logging

12. GC collects?

A) Unmanaged memory
B) Managed memory ✅
C) Database connections
D) Threads

13. Which tool helps detect memory issues?

A) IIS Manager
B) Visual Studio Diagnostic Tools ✅
C) NuGet Manager
D) Windows Firewall

14. Purpose of IDisposable?

A) Compile code
B) Dispose unmanaged resources ✅
C) Debug logs
D) Speed up runtime

15. Best way to prevent memory leaks?

A) Never use Static
B) Use using & proper DI ✅
C) Avoid async
D) Restart server