ASP.NET MVC MCQ Banner

ASP.NET MVC Multiple Choice Questions (MCQs) and Answers

Master ASP.NET MVC with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of ASP.NET MVC concepts. Begin your placement preparation journey now!

Q91

Q91 Which interface is commonly used for Dependency Injection in ASP.NET MVC?

A

IServiceProvider

B

IDependencyResolver

C

IDisposable

D

IControllerFactory

Q92

Q92 What is the main benefit of using Dependency Injection?

A

Faster execution

B

Loose coupling

C

Improved UI rendering

D

Simpler validation

Q93

Q93 Which lifecycle is associated with a Singleton service in DI?

A

Per request

B

Single instance

C

Per controller

D

Multiple instances

Q94

Q94 How do you configure Dependency Injection in ASP.NET MVC?

A

By defining dependencies in RouteConfig

B

Using an IoC container

C

Adding Razor syntax

D

Using Web.config

Q95

Q95 How do you register a service in an IoC container in ASP.NET MVC?

A

container.Register();

B

container.Add();

C

container.Map();

D

container.Bind();

Q96

Q96 How do you resolve a dependency manually in a controller?

A

Use ResolveDependency()

B

Call DependencyResolver.GetService()

C

Use GetDependency()

D

Call Resolve()

Q97

Q97 How do you inject a dependency using a constructor in MVC?

A

Add it to Global.asax

B

Define it in the controller constructor

C

Use a SetDependency() method

D

Modify the RouteConfig

Q98

Q98 A service is not being resolved by the IoC container. What could be wrong?

A

The service is not registered

B

Controller name is invalid

C

View is missing

D

Route is incorrect

Q99

Q99 A Singleton service creates multiple instances. What could be the issue?

A

Service scope is not Singleton

B

Controller is invalid

C

Incorrect routing

D

Model binding failed

Q100

Q100 An injected service throws a null reference exception. What is the issue?

A

Service is not registered

B

Service is misconfigured

C

Controller constructor is missing

D

Both A and B

Q101

Q101 What is Entity Framework (EF) in ASP.NET MVC?

A

A UI framework

B

A database ORM

C

A routing library

D

A dependency injection tool

Q102

Q102 What is the purpose of DbContext in Entity Framework?

A

Manage database schema

B

Provide a bridge between models and database

C

Define routing

D

Validate data annotations

Q103

Q103 How does Entity Framework handle lazy loading?

A

It loads related data automatically

B

It loads only requested data

C

It fetches all related data upfront

D

It does not support lazy loading

Q104

Q104 What is the difference between DbSet and DbContext in EF?

A

DbSet represents collections, DbContext manages database connections

B

Both are equivalent

C

DbContext defines routing, DbSet validates models

D

DbSet handles DI, DbContext does not

Q105

Q105 Which method is used to configure EF mappings using Fluent API?

A

Configure()

B

OnModelCreating()

C

Map()

D

CreateMapping()

Q106

Q106 How do you retrieve all records from a table using Entity Framework?

A

db.TableName.ToList()

B

db.GetAll("TableName")

C

db.TableName.Get()

D

db.FetchAll("TableName")

Q107

Q107 How do you include related entities in a query using EF?

A

Use Include() method

B

Use Join() method

C

Add a new DbSet

D

Use eager loading

Q108

Q108 How do you add a new record to a table using EF?

A

db.Add()

B

db.TableName.Add(entity)

C

db.SaveChanges(entity)

D

db.New(entity)

Q109

Q109 A query using Entity Framework returns no results. What could be wrong?

A

Invalid connection string

B

Lazy loading is disabled

C

DbContext is not disposed

D

Primary key is missing

Q110

Q110 A DbContext instance throws a "disposed" exception. What is the issue?

A

It is being used after being disposed

B

Connection string is invalid

C

Entity model is not defined

D

Primary key is missing

Q111

Q111 What is the purpose of AJAX in ASP.NET MVC?

A

Handle routing

B

Update parts of a page asynchronously

C

Manage database connections

D

Render Razor views

Q112

Q112 Which library is commonly used for AJAX in ASP.NET MVC?

A

jQuery

B

Angular

C

React

D

Knockout

Q113

Q113 What is a Partial View in ASP.NET MVC?

A

A fully rendered view

B

A reusable view component

C

A controller action

D

A database entity

Q114

Q114 How is a Partial View rendered using HTML Helpers?

A

@Html.RenderPartial("ViewName")

B

@Html.Render("ViewName")

C

@Html.Partial("ViewName")

D

@Html.View("ViewName")

Q115

Q115 What is the role of JsonResult in AJAX requests?

A

Return HTML

B

Return JSON data

C

Handle routing

D

Define models

Q116

Q116 How do you make an AJAX GET request using jQuery?

A

$.ajax({type: "GET"})

B

$.get("url")

C

$.ajaxGet("url")

D

$.fetch("url")

Q117

Q117 How do you update a DOM element with data from an AJAX call?

A

Use append()

B

Use load()

C

Use update()

D

Use replace()

Q118

Q118 How do you send data in an AJAX POST request using jQuery?

A

$.ajax({type: "POST", data: data})

B

$.post("url")

C

$.ajaxPost("url")

D

$.fetchPost("url")

Q119

Q119 An AJAX request returns a 404 error. What could be the issue?

A

Invalid URL

B

Missing controller

C

Incorrect data format

D

View not found

Q120

Q120 A Partial View does not render correctly. What could be wrong?

A

View is missing

B

Invalid route

C

Incorrect model passed

D

All of the above

ad verticalad vertical
ad