Home Subjects C# Programming ASP.NET Basics

C# Programming
ASP.NET Basics

C# and .NET for campus placement

9 Q 4 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 1–9 of 9
Topics in C# Programming
Q.1 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.2 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.3 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
Q.4 Medium ASP.NET Basics
In an ASP.NET Core application, where is Dependency Injection configured?
A In the Startup.cs ConfigureServices method
B In the web.config file
C In the appsettings.json file only
D In the Global.asax file
Correct Answer:  A. In the Startup.cs ConfigureServices method
EXPLANATION

Dependency Injection is configured in the ConfigureServices method of Startup.cs (or Program.cs in newer versions).

Test
Q.5 Medium ASP.NET Basics
What is the role of Middleware in ASP.NET Core?
A To process HTTP requests and responses in a pipeline
B To manage database connections
C To encrypt sensitive data
D To compile C# code
Correct Answer:  A. To process HTTP requests and responses in a pipeline
EXPLANATION

Middleware components handle cross-cutting concerns like authentication, logging, and exception handling in the request pipeline.

Test
Q.6 Medium ASP.NET Basics
Which of the following is NOT a built-in state management technique in ASP.NET?
A ViewState
B Session State
C Application State
D Block State
Correct Answer:  D. Block State
EXPLANATION

ViewState, Session State, Application State, and Cookies are valid state management techniques. Block State is not a standard ASP.NET technique.

Test
Q.7 Medium ASP.NET Basics
What is the difference between ASP.NET Framework and ASP.NET Core?
A ASP.NET Core is cross-platform while Framework runs only on Windows
B Framework is newer than Core
C Core only supports MVC pattern
D Framework and Core are identical
Correct Answer:  A. ASP.NET Core is cross-platform while Framework runs only on Windows
EXPLANATION

ASP.NET Core is cross-platform (Windows, Linux, macOS) and open-source, while ASP.NET Framework is Windows-only.

Test
Q.8 Medium ASP.NET Basics
Which attribute is used to mark a method as an HTTP endpoint in ASP.NET Core?
A [Route]
B [HttpGet]
C [ApiController]
D [EndPoint]
Correct Answer:  B. [HttpGet]
EXPLANATION

[HttpGet], [HttpPost], [HttpPut], [HttpDelete] attributes define HTTP methods for controller actions in ASP.NET Core.

Test
Q.9 Medium ASP.NET Basics
In ASP.NET, what is the purpose of the Global.asax file?
A To define application-level events and methods
B To store database connection strings
C To configure web server settings
D To manage user authentication only
Correct Answer:  A. To define application-level events and methods
EXPLANATION

Global.asax handles application-level events like Application_Start, Application_End, and Session_Start.

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