1. DI in ASP.NET Core primarily helps with:
A) Performance
B) Loose coupling & testability
C) UI rendering
D) Deployment
Answer: B
2. Which lifetime creates a new instance per HTTP request?
A) Singleton
B) Scoped
C) Transient
D) ThreadStatic
Answer: B
3. Which DI lifetime should DbContext use?
A) Singleton
B) Scoped
C) Transient
D) Static
Answer: B
4. If a Singleton depends on a Scoped service, what can happen?
A) Faster execution
B) Memory leak
C) Thread lock
D) No effect
Answer: B
5. Where are services registered in .NET Core?
A) Web.config
B) Program.cs
C) AppSettings.json
D) StartupController.cs
Answer: B
Middleware MCQs
6. Middleware executes in:
A) Random order
B) Fixed pipeline sequence
C) Compiler decides
D) Based on thread pool
Answer: B
7. Which method MUST be called in custom middleware?
A) Task.Run
B) builder.Build
C) await next()
D) UseMvc
Answer: C
8. Which is used to add routing?
A) app.UseAuthorization()
B) app.UseRouting()
C) app.UseEndpoints()
D) app.MapControllers()
Answer: B
9. Middleware that runs FIRST for error handling?
A) UseAuthorization
B) UseExceptionHandler
C) UseCors
D) MapEndpoints
Answer: B
10. Real order in ASP.NET Core pipeline?
Answer: B
A)
Auth → Routing → Exception
B)
Exception → Routing → Auth → Endpoint
C)
Endpoint → Auth → Exception
D)
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
Answer: B
12. GC collects?
A) Unmanaged memory
B) Managed memory
C) Database connections
D) Threads
Answer: B
13. Which tool helps detect memory issues?
A) IIS Manager
B) Visual Studio Diagnostic Tools
C) NuGet Manager
D) Windows Firewall
Answer: B
14. Purpose of IDisposable?
A) Compile code
B) Dispose unmanaged resources
C) Debug logs
D) Speed up runtime
Answer: B
15. Best way to prevent memory leaks?
A) Never use Static
B) Use using & proper DI
C) Avoid async
D) Restart server
Answer: B