
Q91
Q91 What is the role of [Authorize] in ASP.NET MVC?
To define routes
To restrict access to actions
To validate models
To render views
Q92
Q92 How can you implement custom authentication in ASP.NET MVC?
Create a custom AuthorizeAttribute
Use HttpContext.User
Modify RouteConfig
Customize ViewBag
Q93
Q93 How do you enable client-side validation in ASP.NET MVC?
Add @Html.EnableClientValidation()
Include jQuery Validation library
Define rules in the Controller
Both A and B
Q94
Q94 How do you check if a user is authenticated in a Controller?
Use HttpContext.IsAuthenticated
Use User.Identity.IsAuthenticated
Use Session["Authenticated"]
Use Authorize.IsValid()
Q95
Q95 How do you validate a model manually in an action?
Use TryValidateModel()
Call ModelState.Clear()
Use ModelState.IsValid
Override the Validate method
Q96
Q96 A validation error is not displayed in the view. What could be the issue?
Validation scripts are missing
Controller is invalid
Route is not defined
Model is null
Q97
Q97 A [Required] validation is ignored on the server-side. What could be wrong?
Model binding failed
DataAnnotations namespace is missing
Client-side validation is disabled
Validation attribute is not applied
Q98
Q98 The [Authorize] attribute is not working as expected. What could be wrong?
Custom attribute is not registered
Authentication middleware is missing
Route is invalid
User role is not defined
Q99
Q99 What is Dependency Injection in ASP.NET MVC?
A pattern for database access
A technique for managing dependencies
A routing mechanism
A way to validate models
Q100
Q100 Which interface is commonly used for Dependency Injection in ASP.NET MVC?
IServiceProvider
IDependencyResolver
IDisposable
IControllerFactory
Q101
Q101 What is the main benefit of using Dependency Injection?
Faster execution
Loose coupling
Improved UI rendering
Simpler validation
Q102
Q102 Which lifecycle is associated with a Singleton service in DI?
Per request
Single instance
Per controller
Multiple instances
Q103
Q103 How do you configure Dependency Injection in ASP.NET MVC?
By defining dependencies in RouteConfig
Using an IoC container
Adding Razor syntax
Using Web.config
Q104
Q104 How do you register a service in an IoC container in ASP.NET MVC?
container.Register
container.Add
container.Map
container.Bind
Q105
Q105 How do you resolve a dependency manually in a controller?
Use ResolveDependency
Call DependencyResolver.GetService
Use GetDependency
Call Resolve
Q106
Q106 How do you inject a dependency using a constructor in MVC?
Add it to Global.asax
Define it in the controller constructor
Use a SetDependency() method
Modify the RouteConfig
Q107
Q107 A service is not being resolved by the IoC container. What could be wrong?
The service is not registered
Controller name is invalid
View is missing
Route is incorrect
Q108
Q108 A Singleton service creates multiple instances. What could be the issue?
Service scope is not Singleton
Controller is invalid
Incorrect routing
Model binding failed
Q109
Q109 An injected service throws a null reference exception. What is the issue?
Service is not registered
Service is misconfigured
Controller constructor is missing
Both A and B
Q110
Q110 What is Entity Framework (EF) in ASP.NET MVC?
A UI framework
A database ORM
A routing library
A dependency injection tool
Q111
Q111 What is the purpose of DbContext in Entity Framework?
Manage database schema
Provide a bridge between models and database
Define routing
Validate data annotations
Q112
Q112 How does Entity Framework handle lazy loading?
It loads related data automatically
It loads only requested data
It fetches all related data upfront
It does not support lazy loading
Q113
Q113 What is the difference between DbSet and DbContext in EF?
DbSet represents collections, DbContext manages database connections
Both are equivalent
DbContext defines routing, DbSet validates models
DbSet handles DI, DbContext does not
Q114
Q114 Which method is used to configure EF mappings using Fluent API?
Configure()
OnModelCreating()
Map()
CreateMapping()
Q115
Q115 How do you retrieve all records from a table using Entity Framework?
db.TableName.ToList()
db.GetAll("TableName")
db.TableName.Get()
db.FetchAll("TableName")
Q116
Q116 How do you include related entities in a query using EF?
Use Include() method
Use Join() method
Add a new DbSet
Use eager loading
Q117
Q117 How do you add a new record to a table using EF?
db.Add()
db.TableName.Add(entity)
db.SaveChanges(entity)
db.New(entity)
Q118
Q118 A query using Entity Framework returns no results. What could be wrong?
Invalid connection string
Lazy loading is disabled
DbContext is not disposed
Primary key is missing
Q119
Q119 A DbContext instance throws a "disposed" exception. What is the issue?
It is being used after being disposed
Connection string is invalid
Entity model is not defined
Primary key is missing
Q120
Q120 What is the purpose of AJAX in ASP.NET MVC?
Handle routing
Update parts of a page asynchronously
Manage database connections
Render Razor views

