Home Subjects C# Programming ASP.NET Basics

C# Programming
ASP.NET Basics

C# and .NET for campus placement

19 Q 4 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 1–10 of 19
Topics in C# Programming
Q.1 Hard ASP.NET Basics
A developer needs to create a RESTful API that returns JSON data. Which ASP.NET approach is most suitable?
A ASP.NET Core Web API with [ApiController]
B ASP.NET Web Forms with controls
C Classic ASP with VBScript
D ASP.NET MVC Views only
Correct Answer:  A. ASP.NET Core Web API with [ApiController]
EXPLANATION

ASP.NET Core Web API with [ApiController] attribute is the modern approach for building RESTful APIs that return JSON.

Test
Q.2 Easy ASP.NET Basics
What does MVC stand for in ASP.NET MVC?
A Model-View-Controller
B Module-Virtual-Component
C Multi-View-Cache
D Main-Variable-Class
Correct Answer:  A. Model-View-Controller
EXPLANATION

MVC (Model-View-Controller) is an architectural pattern separating data (Model), presentation (View), and business logic (Controller).

Test
Q.3 Hard ASP.NET Basics
In ASP.NET Core, which method is used to register services in the dependency injection container?
A services.AddScoped(), services.AddSingleton(), services.AddTransient()
B services.Register()
C services.Inject()
D services.Configure()
Correct Answer:  A. services.AddScoped(), services.AddSingleton(), services.AddTransient()
EXPLANATION

AddScoped, AddSingleton, and AddTransient are methods to register services with different lifetimes in ASP.NET Core DI.

Test
Q.4 Medium ASP.NET Basics
What is Entity Framework in ASP.NET context?
A An ORM (Object-Relational Mapping) tool for database operations
B A JavaScript framework
C A security framework
D A caching mechanism
Correct Answer:  A. An ORM (Object-Relational Mapping) tool for database operations
EXPLANATION

Entity Framework is Microsoft's ORM that allows developers to work with databases using .NET objects instead of raw SQL.

Test
Q.5 Hard ASP.NET Basics
An e-commerce application needs to handle concurrent user requests efficiently. Which ASP.NET Core feature is most suitable?
A Async/Await with Task-based operations
B Synchronous request processing
C Single-threaded execution
D Blocking I/O operations
Correct Answer:  A. Async/Await with Task-based operations
EXPLANATION

Async/Await enables non-blocking I/O operations, allowing ASP.NET Core to handle more concurrent requests efficiently.

Test
Q.6 Easy ASP.NET Basics
In ASP.NET Core, what is the purpose of the appsettings.json file?
A To store application configuration settings
B To define database schema
C To configure IIS settings
D To manage user authentication only
Correct Answer:  A. To store application configuration settings
EXPLANATION

appsettings.json stores application configuration like connection strings, logging levels, and custom settings.

Test
Q.7 Hard ASP.NET Basics
What is the correct order of Page Lifecycle events in ASP.NET Web Forms?
A Init → Load → EventHandling → Render → Unload
B Load → Init → EventHandling → Render → Unload
C Init → Load → Render → EventHandling → Unload
D Load → Init → Render → EventHandling → Unload
Correct Answer:  A. Init → Load → EventHandling → Render → Unload
EXPLANATION

ASP.NET Web Forms lifecycle: Init → Load → Event Handling (ViewState restored) → Render → Unload.

Test
Q.8 Hard ASP.NET Basics
A web application needs to store a user preference that persists across multiple browser sessions. Which state management technique is most appropriate?
A Database with user ID
B ViewState
C Session State
D Application State
Correct Answer:  A. Database with user ID
EXPLANATION

For persistent data across multiple sessions, database storage is the best approach. Session State is temporary and Application State is server-wide.

Test
Q.9 Medium ASP.NET Basics
Which of the following methods is used to pass data from Controller to View in ASP.NET MVC?
A ViewBag and ViewData
B Session State only
C Query strings only
D Cookies only
Correct Answer:  A. ViewBag and ViewData
EXPLANATION

ViewBag (dynamic) and ViewData (dictionary) are common ways to pass data from Controller to View in ASP.NET MVC.

Test
Q.10 Medium ASP.NET Basics
What is the purpose of the [ValidateAntiForgeryToken] attribute in ASP.NET MVC?
A To prevent Cross-Site Request Forgery attacks
B To validate user input format
C To encrypt form data
D To authenticate user sessions
Correct Answer:  A. To prevent Cross-Site Request Forgery attacks
EXPLANATION

[ValidateAntiForgeryToken] verifies that form submissions come from your application, preventing CSRF attacks.

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips