C# Mastery Hub
Home
Challenges
Discussion
Lessons
Core Topics
C# Fundamentals
Console Applications
Classes & OOP
Windows Forms
ASP.NET Core
SQL Server
VS & SQL Connection
RDLC Reports
.NET MAUI
Getting Started
Getting Started
Website Development
SEO Guide
Security
Project Workflow
Extra Topics
Cloud & Deployment
AWS Cloud
Deployment
About
Contact
Test Your Knowledge
ASP.NET Core Quiz
Answer all questions to test your understanding
1
What does MVC stand for?
Model-View-Controller
Model-View-Component
Module-View-Controller
Model-Variable-Controller
2
What is the main difference between MVC and Razor Pages?
Razor Pages is page-focused, MVC is controller-focused
MVC is page-focused, Razor Pages is controller-focused
They are exactly the same
MVC uses C#, Razor Pages uses JavaScript
3
When should you use Razor Pages over MVC?
For complex applications with large teams
For page-focused applications and smaller projects
For building REST APIs
For all types of applications
4
What are the three components of the MVC pattern?
Model, View, Controller
Model, View, Component
Module, View, Controller
Model, Variable, Controller
5
Which approach is typically simpler for beginners?
MVC
Razor Pages
Both are equally complex
Neither is suitable for beginners
6
What is the PageModel in Razor Pages?
The HTML template
The code-behind file for a Razor Page
The database model
The CSS stylesheet
7
How do you define a custom route in Razor Pages?
Using the @page directive with a route template
Using the [Route] attribute on the PageModel
Using the MapRoute method
Using the route.config file
8
What is the default routing convention in Razor Pages?
/Pages/PageName
/PageName
The folder structure determines the URL path
Custom routes must always be defined
9
Which route constraint ensures a parameter is a valid integer?
{id:int}
{id:integer}
{id:num}
{id:number}
10
How do you access a route parameter in the PageModel?
As a property decorated with [BindProperty]
As a parameter in the OnGet method
Using the Request object
All of the above
11
What are Tag Helpers in ASP.NET Core?
Server-side components that participate in HTML rendering
Client-side JavaScript libraries
CSS frameworks
Database helpers
12
Which Tag Helper creates a link to another page?
Anchor Tag Helper (asp-page)
Link Tag Helper
Route Tag Helper
Navigation Tag Helper
13
What does the asp-for Tag Helper do?
Generates HTML based on the model property
Creates a link to a page
Validates form input
Styles HTML elements
14
What is the purpose of the asp-validation-summary Tag Helper?
Displays a summary of validation errors
Validates a single field
Styles the form
Creates a validation list
15
Can you create custom Tag Helpers in ASP.NET Core?
No, only built-in Tag Helpers are available
Yes, by inheriting from TagHelper class
Only in MVC applications
Only for form validation
16
What is model binding in ASP.NET Core?
Automatically mapping HTTP request data to C# objects
Creating database models
Styling HTML elements
Validating user input
17
Which attribute is used to bind a property to form data?
[BindProperty]
[FormData]
[RequestData]
[MapProperty]
18
What is the Post-Redirect-Get (PRG) pattern?
Redirecting to another page after a POST to prevent duplicate submissions
Getting data before posting
Posting data to multiple pages
Redirecting all POST requests
19
How do you handle form submission in Razor Pages?
Using OnPost method in the PageModel
Using OnSubmit method
Using HandlePost method
Using FormHandler attribute
20
What is the purpose of the [BindProperty] attribute?
To bind model properties to request data
To create database tables
To style HTML elements
To validate input
21
What are Data Annotations in ASP.NET Core?
Attributes used for validation and metadata
CSS classes for styling
JavaScript functions
Database migrations
22
Which attribute marks a property as required?
[Required]
[Mandatory]
[NotNull]
[Must]
23
How do you specify a custom error message for validation?
Using the ErrorMessage property of the validation attribute
Using a separate error file
Using the ModelState
Using ViewData
24
What does ModelState.IsValid check?
Whether the model passes all validation rules
Whether the model is null
Whether the database is valid
Whether the view is valid
25
Can you create custom validation attributes?
No, only built-in attributes are allowed
Yes, by inheriting from ValidationAttribute
Only for specific data types
Only in MVC applications
26
What is a Layout in Razor Pages?
A template that provides a consistent structure across pages
A database schema
A CSS file
A JavaScript file
27
What is the purpose of @RenderBody() in a Layout?
Renders the content of the current page
Renders the header
Renders the footer
Renders the navigation
28
How do you specify which Layout a page should use?
Using the Layout property in the page
Using the _ViewStart.cshtml file
Using the [Layout] attribute
Both A and B
29
What is a Partial View in Razor Pages?
A reusable UI component
A complete page
A database view
A CSS class
30
How do you include a Partial View in a Razor Page?
Using @await Html.PartialAsync()
Using @await Html.RenderPartialAsync()
Using the <partial> Tag Helper
All of the above
31
What is Dependency Injection (DI)?
A pattern where objects receive dependencies from an external source
A pattern where objects create their own dependencies
A database pattern
A UI pattern
32
Which service lifetime creates a new instance every time it's requested?
Singleton
Scoped
Transient
PerRequest
33
Which service lifetime creates one instance per HTTP request?
Singleton
Scoped
Transient
PerRequest
34
Which service lifetime creates one instance for the entire application lifetime?
Singleton
Scoped
Transient
PerRequest
35
How do you register a service in ASP.NET Core?
Using builder.Services in Program.cs
Using the [Inject] attribute
Using the Startup.cs file
Using the appsettings.json file
36
What does CRUD stand for?
Create, Read, Update, Delete
Create, Review, Update, Delete
Code, Run, Update, Deploy
Create, Read, Update, Display
37
Which method is used to add a new entity to the database in EF Core?
Add()
Insert()
Create()
Save()
38
What is the purpose of EntityState.Modified?
To mark an entity as modified for updating
To mark an entity as new
To delete an entity
To detach an entity
39
How do you delete an entity in EF Core?
Remove()
Delete()
Erase()
Drop()
40
What is the purpose of Include() in EF Core?
To load related data (eager loading)
To add a new entity
To delete an entity
To update an entity
Submit Quiz