wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

KAPITTEL 1: ASP.NET Core MVC - grunnleggende

Total questions: 125

Worksheet time: 1hrs 3mins

Name
Class
Date
1.

In MVC, which component is responsible for rendering HTML to the client?

a)

Model classes holding data

b)

Repository layer abstractions

c)

View component using .cshtml

d)

Controller methods orchestrating

2.

Which folder typically contains classes like Obstacle, Report, User, and Organization as core domain entities?

a)

Views folder for Razor

b)

Models folder for DTOs

c)

Domain folder for main models

d)

Services folder for business

3.

What is the primary responsibility of Controllers in an ASP.NET Core MVC project?

a)

Handle requests and route logic

b)

Serve static client scripts

c)

Render Razor HTML views

d)

Persist data to database

4.

Which Program.cs setup step enables constructor injection of app services throughout the app?

a)

Register services for DI

b)

Configure Identity auth

c)

Set database connections

d)

Define endpoint routing

5.

Which routing pattern represents the conventional route template in ASP.NET Core MVC?

a)

{controller}/{action}/{id?}

b)

/api/{resource}/{id}

c)

/{area}/{page}/{id}

d)

/v1/{entity}/{verb}

6.

Which statement about GET actions is accurate in MVC controllers?

a)

Send data and modify state

b)

Require anti-forgery token

c)

Cannot be cached at all

d)

Retrieve data without changes

7.

Which attribute is commonly applied to secure POST actions against CSRF?

a)

AllowAnonymous attribute

b)

ValidateAntiForgeryToken attribute

c)

Authorize attribute only

d)

ResponseCache attribute

8.

Which service layer folder would likely include UserService and OrganizationService implementations?

a)

Services containing business logic

b)

Repository for EF Core access

c)

DataContext for connections

d)

Views for Razor pages

9.

When integrating a map feature using JavaScript and Leaflet, which approach correctly sends user interactions to the server?

a)

AJAX requests from map.js

b)

Form posts from Razor only

c)

WebSockets by default

d)

Static JSON files export

10.

Which statement best characterizes the GET method in ASP.NET Core MVC?

a)

Requires anti-forgery validation

b)

Fetches data without side effects

c)

Returns different results for same URL

d)

Submits data and changes state

11.

In a controller, which attribute should decorate an action that processes a form submission to create a record?

a)

[Route] attribute

b)

[HttpGet] attribute

c)

[HttpPost] attribute

d)

[Authorize] attribute

12.

A page displays product details using the same URL across requests. Which behavior aligns with best practice for that endpoint?

a)

Require anti-forgery token on each request

b)

Disable caching to prevent stale content

c)

Modify database on each view request

d)

Allow response caching for identical queries

13.

Which scenario most clearly requires an anti-forgery token in ASP.NET Core MVC?

a)

Submitting a profile update form

b)

Navigating to a read-only dashboard

c)

Loading a list of products

d)

Fetching static assets like CSS

14.

You must design an order submission endpoint. Which choice reflects safe, cache behavior and data impact?

a)

GET: safe, cacheable, no data change

b)

POST: safe, cacheable, no data change

c)

GET: unsafe, not cacheable, changes data

d)

POST: may change data, not cacheable, needs CSRF protection

15.

Which library is commonly used to render interactive maps in a client-side map.js for an ASP.NET Core MVC app?

a)

Dapper micro-ORM utilities

b)

Bootstrap responsive styling

c)

SignalR real-time messaging

d)

Leaflet library for web maps

16.

What is the primary purpose of making an AJAX request from map.js when a user adds a marker?

a)

Send marker data to server asynchronously

b)

Render server-side Razor view template

c)

Generate anti-forgery token automatically

d)

Invalidate all user session entries

17.

In the draft submission workflow, what should happen immediately after loading the draft from session?

a)

Validate the model for consistency

b)

Remove the draft from the session

c)

Attach obstacles to the report

d)

Create a new database report

18.

Which statement best describes session usage for map-related drafts?

a)

Temporarily store draft before database

b)

Permanently persist data across servers

c)

Encrypt Razor views during rendering

d)

Cache static files for faster delivery

19.

A form in an ASP.NET Core MVC Razor view needs CSRF protection. Which element provides the required token?

a)

Html.AntiForgeryToken helper

b)

Leaflet initialization code

c)

AJAX GET request header

d)

Session.Remove on draft key

20.

You are implementing SubmitDraft in a controller. Which ordered step correctly comes after fetching the logged-in user?

a)

Create the report entity next

b)

Validate the draft model

c)

Delete the draft from session

d)

Initialize the Leaflet map

21.

Why should POST requests that finalize a draft not be cached by clients or proxies?

a)

They modify server-side state

b)

They include large map tiles

c)

They are always unauthenticated

d)

They return identical responses

22.

When retrieving a saved draft from session, which API correctly deserializes a typed object?

a)

TempData.Peek("DraftKey")

b)

HttpContext.Request.Query.TryGetValue

c)

HttpContext.Session.Get

d)

ViewData.GetModel

23.

Which statement best describes Entity Framework Core in an ASP.NET Core MVC application?

a)

It is a caching layer for session storage

b)

It is a frontend library for UI rendering

c)

It is a NoSQL engine replacing SQL Server

d)

It is an ORM translating objects to tables

24.

In a solution using ApplicationContext and AuthDbContext, what is the primary responsibility of AuthDbContext?

a)

Handling view rendering and layouts

b)

Configuring client-side routing

c)

Storing obstacles and reports

d)

Managing users, roles, organizations

25.

What EF Core set represents a table for obstacles in the database?

a)

DbSet property in context

b)

List in a view model

c)

IEnumerable in a controller

d)

ObservableCollection on client

26.

Which method pair is the correct sequence to persist a new entity with EF Core?

a)

ToListAsync then Include

b)

Where then FirstOrDefaultAsync

c)

SaveChangesAsync then AddAsync

d)

AddAsync then SaveChangesAsync

27.

Choose the statement that explains OnModelCreating in EF Core.

a)

Handles HTTP routing and endpoints

b)

Defines keys, relationships, seed data

c)

Generates antiforgery tokens for forms

d)

Executes client-side validations only

28.

A developer needs related Report data when querying Obstacles. Which API usage achieves this?

a)

Include(o => o.Report) on the query

b)

Select new Report from context

c)

Join Reports using raw SQL strings

d)

Load all tables and filter in memory

29.

Why are parameterized queries important when EF Core translates LINQ to SQL?

a)

They protect against SQL injection attacks

b)

They improve client-side rendering speed

c)

They disable migrations by default

d)

They enforce MVC controller naming

30.

When is ExecuteSqlRaw appropriate in this architecture?

a)

Only for migration handling, not user data

b)

For caching session state across requests

c)

For every data read to improve speed

d)

For building views and controllers

31.

Which statement best describes how Entity Framework Core handles SQL when using LINQ queries?

a)

It auto-generates parameterized SQL from LINQ

b)

It requires manual SQL strings for every query

c)

It only supports raw SQL without parameters

d)

It compiles LINQ to non-parameterized SQL

32.

You need to fetch all rows from the Obstacles table using EF Core. Which LINQ call aligns with the SQL produced?

a)

_context.Obstacles.RemoveRange() → SELECT * FROM Obstacles

b)

_context.Obstacles.ToListAsync() → SELECT * FROM Obstacles

c)

_context.Obstacles.FindAsync() → SELECT * FROM Obstacles

d)

_context.Obstacles.Update() → SELECT * FROM Obstacles

33.

A query must filter by Id using user input while preventing SQL injection. Which EF Core pattern achieves this?

a)

ExecuteSqlRaw with user-supplied id

b)

Build dynamic SQL via string.Format

c)

Concatenate id into a SQL string

d)

Where(o => o.Id == id) uses parameters

34.

When is ExecuteSqlRaw appropriate in an ASP.NET Core app that uses EF Core?

a)

For joining related tables in LINQ

b)

For everyday queries with user input

c)

For replacing all LINQ queries in production

d)

For migration or admin scripts without user data

35.

Which statement best defines the Repository Pattern in ASP.NET Core MVC?

a)

An abstraction layer for data access operations

b)

A class exposing database tables directly

c)

A configuration file storing connection strings

d)

A UI component rendering controller views

36.

In a typical implementation, what does a controller depend on when using the Repository Pattern?

a)

Concrete repository class directly

b)

Static helper for SQL queries

c)

Entity Framework DbContext instance

d)

Repository interface such as IObstacleRepository

37.

Which benefit most directly supports unit testing when applying the Repository Pattern?

a)

Stronger runtime type safety

b)

Ability to mock the repository interface

c)

Automatic query optimization features

d)

Reduced need for dependency injection

38.

Choose the primary purpose of database abstraction provided by a repository.

a)

Replace controllers with service singletons

b)

Expose how the data is fetched internally

c)

Generate SQL scripts for migrations

d)

Hide data access details behind an interface

39.

You need to switch from SQL Server to PostgreSQL without changing controller code. Which approach aligns with the Repository Pattern?

a)

Swap the concrete repository implementing the interface

b)

Embed raw SQL strings inside each controller

c)

Use a static global DbContext shared everywhere

d)

Modify all controller actions to new queries

40.

A team wants more maintainable code and reuse across features. Which Repository Pattern characteristic addresses this goal?

a)

Queries scattered through UI components

b)

Interfaces removed to simplify design

c)

Repositories encapsulate CRUD operations

d)

Controllers own data retrieval logic

41.

Which statement best describes Dependency Injection in ASP.NET Core MVC?

a)

Classes create their own required objects

b)

Services are only available as singletons

c)

A system provides required objects to classes

d)

Controllers directly instantiate repository classes

42.

What is the primary purpose of registering a service with AddScoped in Program.cs?

a)

Create one instance for the entire application

b)

Create a new instance for each dependency resolution

c)

Create a new instance per controller method

d)

Create one instance per HTTP request scope

43.

Given an interface IObstacleRepository and class ObstacleRepository, how should the controller receive this dependency?

a)

Resolve ObstacleRepository using ServiceLocator in the action

b)

Inject IObstacleRepository via the controller constructor

c)

Use a static field to hold the repository

d)

Instantiate ObstacleRepository inside each action

44.

Which Program.cs registration correctly binds an interface to its implementation as scoped?

a)

builder.Services.AddScoped();

b)

builder.Services.AddScoped();

c)

builder.Services.AddTransient();

d)

builder.Services.AddSingleton(new ObstacleRepository());

45.

Why does using interfaces with DI improve testability in controllers?

a)

Interfaces allow mocking of dependencies

b)

Interfaces force runtime compilation

c)

Interfaces reduce the number of controller actions

d)

Interfaces eliminate the need for service registration

46.

What is the primary purpose of authentication in an ASP.NET Core MVC app?

a)

Log performance metrics only

b)

Encrypt all traffic globally

c)

Grant permissions to data

d)

Verify user identity claims

47.

Which ASP.NET Core component typically handles user sign-in and identity verification?

a)

ASP.NET Core Identity

b)

Entity Framework Core

c)

Razor View Engine

d)

Kestrel Web Server

48.

Arrange the typical login flow: user submits credentials, system validates, cookie issued, user considered signed in. Which step occurs immediately after validation succeeds?

a)

Authentication cookie is created

b)

Password is rehashed again

c)

Session state is abandoned

d)

Two-factor is disabled globally

49.

During password sign-in, which API commonly checks the provided username and password?

a)

SignInManager.PasswordSignInAsync

b)

HttpContext.SignOutAsync

c)

UserManager.AddToRoleAsync

d)

DbContext.SaveChangesAsync

50.

Which combination of cookie flags helps reduce theft or misuse of authentication cookies?

a)

HttpOnly, Secure, SameSite

b)

Unsigned, Plain, CrossSite

c)

Persistent, Large, PathWide

d)

Readable, Shared, AnyOrigin

51.

A strong password policy is configured with minimum length and character diversity. Which set best matches typical complexity requirements?

a)

At least 4 characters any printable characters

b)

At least 10 letters all lowercase only

c)

Exactly 6 digits only with no letters

d)

At least 6 characters, uppercase and lowercase, digits and symbols

52.

A user logs in successfully. What does the authentication cookie represent for subsequent requests?

a)

A compiled Razor view cache

b)

Proof the user is signed in

c)

An encryption key for files

d)

A database connection string

53.

What is the primary purpose of authorization in an ASP.NET Core MVC app?

a)

Validate password complexity requirements

b)

Verify identity during sign-in

c)

Determine what actions a user may perform

d)

Encrypt cookies for secure storage

54.

Which attribute restricts a controller action to users in specified roles?

a)

[RequireHttps] attribute on actions

b)

[AllowAnonymous] attribute usage

c)

[Authorize] attribute with Roles

d)

[ValidateAntiForgeryToken] attribute

55.

Given roles SuperAdmin, Registrar, and FlightCrew, which role should approve or reject incident barriers?

a)

No role can approve or reject

b)

FlightCrew approves and rejects only

c)

Registrar handles approve or reject

d)

SuperAdmin manages every feature

56.

You need an action accessible to both Registrar and SuperAdmin. Which configuration fits best?

a)

[Authorize(Roles="Registrar,SuperAdmin")] on action

b)

[Authorize] without any roles specified

c)

User.IsInRole("FlightCrew") check only

d)

DenyAnonymousUsers middleware usage

57.

A page must be visible only to SuperAdmin. What is the simplest implementation approach?

a)

Check User.IsInRole in Razor view

b)

Add role to cookie manually

c)

Apply [Authorize(Roles="SuperAdmin")]

d)

Hide the link in navigation only

58.

During runtime, you must branch logic if the current user is SuperAdmin. What code-level check should you use?

a)

User.IsInRole("SuperAdmin") condition

b)

IOptions comparison

c)

HttpContext.SignInManager method call

d)

ModelState.IsValid boolean check

59.

Where are application roles typically defined when using ASP.NET Core Identity with Entity Framework Core?

a)

Stored in appsettings.json only

b)

Hardcoded in controller constructors

c)

In AuthDbContext via model configuration

d)

Inside Startup.cs Configure method

60.

What is the primary purpose of seed data for roles in an ASP.NET Core Identity setup?

a)

Generate cookies for sign-in

b)

Encrypt role names for storage

c)

Log failed role assignments

d)

Create initial roles at deployment

61.

During user registration, how are roles usually assigned in an Identity-based MVC application?

a)

Never assigned automatically

b)

Manually via SQL after deployment

c)

Only after first successful login

d)

Assigned at registration workflow

62.

Which statement best differentiates public registration versus admin registration in a role‑based system?

a)

Neither requires any approval process

b)

Public users auto‑approved; admins need review

c)

Public users need approval; admins auto‑approved

d)

Both require manual approval by staff

63.

Which organizational roles are most likely included for an aviation obstacle management system using ASP.NET Core Identity?

a)

Sales, Marketing, HR assistants

b)

Drivers, Gardeners, Warehouse staff

c)

Teachers, Students, Librarians

d)

Kartverket, Police, Norwegian Air Force

64.

You are designing authorization filters for controllers. Which attribute correctly restricts an action to SuperAdmin only while keeping code maintainable?

a)

Checking User.IsInRole in every action

b)

Using HttpContext.Items for flags

c)

[Authorize(Roles="SuperAdmin")] attribute

d)

Hiding links in Razor views only

65.

Which statement best defines SQL Injection in web applications?

a)

An attacker forces the server to run their SQL

b)

A user optimizes queries for faster performance

c)

A database compresses data to save storage

d)

An administrator schedules maintenance tasks

66.

Which example illustrates a SQL Injection payload appended to input?

a)

5; DROP TABLE Obstacles;

b)

WHERE Id = @id parameter

c)

SELECT * FROM Obstacles

d)

CREATE INDEX ON Obstacles

67.

Why do parameterized queries mitigate SQL Injection risks?

a)

ORMs block all write operations by default

b)

Indexes automatically validate user input

c)

Queries are always encrypted at rest

d)

Values are bound as parameters, not concatenated

68.

In Entity Framework Core, which LINQ query is considered safe against injection when filtering by Id?

a)

SELECT Obstacles FROM context without WHERE

b)

_context.Database.ExecuteSqlRaw("SELECT * FROM Obstacles")

c)

$"SELECT * FROM Obstacles WHERE Id = {id}"

d)

_context.Obstacles.Where(o => o.Id == id)

69.

When EF Core translates a safe LINQ filter by Id, which SQL form does it generate?

a)

SELECT * FROM Obstacles WHERE Id = id

b)

SELECT * FROM Obstacles WHERE Id LIKE id%

c)

SELECT * FROM Obstacles WHERE Id = @id

d)

SELECT * FROM Obstacles WHERE Id = 'id'

70.

Which statement best defines CSRF in web applications?

a)

A method to encrypt sensitive cookies

b)

A bug causing server-side crashes

c)

A header blocking third-party scripts

d)

An attack forging cross-site requests

71.

In a CSRF attack, what does the attacker typically achieve?

a)

Inject executable JavaScript into views

b)

Steal database credentials directly

c)

Trigger actions without the user's awareness

d)

Bypass TLS and downgrade HTTPS

72.

What primary mechanism mitigates CSRF in ASP.NET Core MVC?

a)

SQL parameterization

b)

CORS preflight checks

c)

X-Content-Type-Options

d)

Anti-forgery tokens

73.

Where is the anti-forgery token usually generated in an ASP.NET Core app?

a)

By the CDN caching layer

b)

In the browser via client script

c)

On the server during form rendering

d)

Inside the database engine

74.

When must the anti-forgery token be included to validate a state-changing request?

a)

With POST requests to protected endpoints

b)

Only with GET requests for pages

c)

Only when cookies are disabled

d)

With any request using HTTP/2

75.

Which attribute enforces token validation on MVC POST actions?

a)

ProducesResponseType

b)

RequireHttps

c)

Authorize

d)

ValidateAntiForgeryToken

76.

How can JavaScript send the anti-forgery token during AJAX calls in ASP.NET Core?

a)

Store the token inside localStorage only

b)

Send cookies without any token

c)

Disable validation for AJAX endpoints

d)

Read the token and add it to the request

77.

Which statement best defines Cross-Site Scripting (XSS) in web applications?

a)

Stealing cookies via insecure HTTPS channels

b)

Exploiting SQL queries through user input

c)

Bypassing server-side input validation checks

d)

Injecting malicious JavaScript into a site

78.

In Razor Views, what primary defense reduces XSS risk when rendering user-provided content?

a)

Blocking cookies for authenticated users

b)

Manual URL encoding for all links

c)

Automatic HTML escaping of output

d)

Disabling JavaScript in the browser

79.

Which HTTP response header defines allowed script sources to mitigate XSS?

a)

X-Frame-Options header

b)

Content-Security-Policy (CSP) header

c)

X-Content-Type-Options header

d)

X-XSS-Protection header

80.

A site returns the header: X-XSS-Protection: 1; mode=block. What does this primarily instruct compatible browsers to do?

a)

Force HTTPS for all external resources

b)

Disable all inline styles and fonts

c)

Enable built-in XSS filters and block attacks

d)

Prevent MIME type sniffing for scripts

81.

You must design a three-layer XSS defense for an MVC app. Which combination aligns with a layered approach?

a)

SQL parameterization, CSP policy, gzip

b)

Razor escaping, CSP policy, X-XSS-Protection

c)

Server caching, CDN, HTTP keep-alive

d)

Cookie flags, CORS headers, CSP

82.

Given CSP: default-src 'self'; script-src 'self', which behavior is most accurate?

a)

Inline JavaScript executes without restriction

b)

Scripts load only from the same origin

c)

Images can load from any external domain

d)

Stylesheets must come from data URLs

83.

Which statement best describes unit testing in an ASP.NET Core MVC solution?

a)

Tests isolated single components only

b)

Tests full controller request pipelines

c)

Tests security headers in production

d)

Tests database access with live server

84.

In controller testing, what is a common practice to handle external services?

a)

Mock dependencies for isolation

b)

Use real services in staging

c)

Bypass services with manual calls

d)

Disable services during tests

85.

Repository testing primarily verifies which concern?

a)

View rendering with Razor pages

b)

Client-side JavaScript execution

c)

Authorization policies for roles

d)

Data access behavior and queries

86.

Security testing in an MVC app typically includes which check?

a)

CPU usage under load tests

b)

Size of compiled assemblies

c)

Number of integration endpoints

d)

Presence of security headers

87.

Match the test structure steps to their purpose using GOAL, LOGIC, RESULT.

a)

RESULT defines expected outcome

b)

LOGIC defines how to test

c)

GOAL defines what to test

d)

None of these are correct

88.

Which test type validates the system end-to-end across components?

a)

Controller tests for actions

b)

Security tests for headers

c)

Unit tests for single methods

d)

Integration tests across the system

89.

You need to verify a controller returns a redirect when a repository reports no data. Which testing approach fits best?

a)

Security test for CSP headers

b)

Integration test without mocks

c)

Unit test with live database

d)

Controller test with mocked repository

90.

A team chooses an InMemory database to validate repository methods. What is the primary benefit in this context?

a)

Automatic security policy setup

b)

Fast, isolated data operations

c)

Accurate production traffic

d)

Enhanced client-side caching

91.

Which statement best describes Docker in modern application deployment?

a)

Virtual machine hypervisor for full OS images

b)

Container technology packaging apps and dependencies

c)

Cloud orchestration platform for autoscaling clusters

d)

Source control system for microservices revisions

92.

In a typical docker-compose.yml for an ASP.NET Core app with MariaDB, which two services are defined?

a)

aspnet app and mariadb

b)

frontend and redis

c)

api gateway and kafka

d)

webapp and mongodb

93.

What is the primary benefit of containerization for deployment?

a)

Maximizes hardware virtualization overhead

b)

Ensures consistent runtime across environments

c)

Eliminates need for application configuration

d)

Requires dedicated physical servers for apps

94.

Which port mapping is commonly shown for the web application in the provided scenario?

a)

8080:8080 for app service

b)

80:8080 for app service

c)

443:5000 for app service

d)

3307:3306 for app service

95.

What happens first when running docker-compose for this stack?

a)

Docker starts the MariaDB container

b)

Docker builds the ASP.NET application

c)

Application migrations execute immediately

d)

The app connects to the database

96.

Which step indicates the application becoming operational with its database?

a)

Images are pushed to a registry

b)

Ports are closed to external traffic

c)

Docker daemon restarts the host

d)

The app connects to the database

97.

After all steps complete, how are the components running?

a)

As local processes without isolation

b)

In containers managed by Docker

c)

On serverless functions only

d)

In separate VMs with full OS

98.

Which statement best describes MariaDB in the context of web application development?

a)

Non-relational store for documents

b)

Relational database storing data in tables

c)

Message queue for background jobs

d)

In-memory cache for session data

99.

Why might a team choose MariaDB for an ASP.NET Core MVC project?

a)

Optimized only for NoSQL workloads

b)

Closed source with paid support

c)

Limited compatibility with EF Core

d)

Open source, reliable, works well with EF

100.

Which comparison between MySQL and MariaDB is most accurate for typical usage?

a)

MySQL is only for Windows servers

b)

They are entirely different engines

c)

They are nearly identical for most tasks

d)

MariaDB cannot run SQL joins

101.

Given the connection string 'Server=mariadb;Database=Kartverketdb;User=root;Password=root123', which change correctly targets a different database name while keeping other settings the same?

a)

Server=sql;Database=Kartverketdb;User=admin;Password=pass

b)

Server=mariadb;Database=ReportsDb;User=root;Password=root123

c)

Server=localhost;Database=ReportsDb;User=sa;Password=pass

d)

Server=mysql;Database=Kartverketdb;User=root;Password=root123

102.

In a relational database schema for an MVC app, which relationship example aligns with typical foreign-key usage?

a)

Middleware to Database as one-to-many

b)

Controller to View as one-to-one

c)

User to Organization as many-to-many

d)

Report to Obstacles as one-to-many

103.

When querying related data using Entity Framework Core, which method helps eagerly load relationships like Obstacles with their Report?

a)

AddRange

b)

ExecuteScalar

c)

Include

d)

SaveChanges

104.

In a relational database, what role does a foreign key primarily serve?

a)

Optimize query execution plans

b)

Store large binary objects

c)

Link rows between related tables

d)

Identify unique rows in a table

105.

Which scenario best exemplifies a one-to-many relationship in an EF Core domain?

a)

Many Users have many Roles

b)

One Report has many Obstacles

c)

One User belongs to many Organizations

d)

Many Organizations belong to one User

106.

To eagerly fetch related data for Obstacles and their Report in EF Core, which method call should be used?

a)

_context.Obstacles.Select(o => o.Report)

b)

_context.Obstacles.Include(o => o.Report)

c)

_context.Obstacles.Load(o => o.Report)

d)

_context.Obstacles.Attach(o => o.Report)

107.

Which statement correctly describes a many-to-one relationship?

a)

One entity references itself in many rows

b)

One child references many parents

c)

Many child entities reference one parent

d)

Many parent entities reference one child

108.

In EF Core, what is the typical effect of using Include on a query?

a)

Deletes orphaned related entities

b)

Performs lazy loading of related entities

c)

Adds a join to load related entities

d)

Creates new related entities automatically

109.

Which file type is used to create Razor Views in an ASP.NET Core MVC application?

a)

.cshtml files for views

b)

.razor files for views

c)

.html files for views

d)

.aspx files for views

110.

In the frontend stack described, what is the primary purpose of Bootstrap?

a)

Database connectivity

b)

Server-side rendering

c)

Styling and UI components

d)

Client-side routing support

111.

Which statement best describes Razor Views in ASP.NET Core MVC?

a)

JavaScript-only templates

b)

HTML mixed with C# code

c)

CSS-only components

d)

XML-based view files

112.

A project includes map.js and draft.js. What is the most likely responsibility of these files?

a)

Unit testing, integration tests

b)

Authentication, authorization

c)

Map for geolocation, form handling

d)

Data seeding, migrations

113.

You need the UI to adapt well on iPad and PC. Which concept should you apply?

a)

Shadow DOM encapsulation

b)

Progressive enhancement approach

c)

Server-side caching rules

d)

Responsive design techniques

114.

In Razor Views, which directive is commonly used to pass data from the controller to the view?

a)

@page directive for data

b)

@using directive for data

c)

@Model directive for data

d)

@inject directive for data

115.

In ASP.NET Core using EF Core, what is the primary purpose of a database migration?

a)

Modify data seeding values across environments

b)

Update database structure to match models

c)

Optimize query performance for specific endpoints

d)

Enable real-time syncing between contexts and views

116.

Which statement best describes how EF Core handles SQL during migrations?

a)

It uses stored procedures created by controllers

b)

It compiles Razor views into SQL commands

c)

It generates SQL from model definitions

d)

It requires hand-written SQL for every change

117.

You added a new property to an entity. Which action correctly applies the corresponding schema change to the database?

a)

Run dotnet ef database update after creating a migration

b)

Call the controller constructor with a repository instance

c)

Restart the web app without adding a migration

d)

Manually edit tables using the SQL Server GUI

118.

A team wants migrations to apply without manual commands during deployment. Which approach aligns with this goal?

a)

Use AJAX requests to call the obstacles controller

b)

Trigger updates by posting a form with validation

c)

Execute update statements from a Razor view during rendering

d)

Configure migrations to run automatically at application startup

119.

In a controller using the Repository pattern, what is the primary benefit of injecting an interface like IObstacleRepository into the constructor?

a)

Guarantees database transactions succeed

b)

Allows automatic Razor view compilation

c)

Enables loose coupling and testability

d)

Improves runtime reflection performance

120.

A POST action is decorated with [ValidateAntiForgeryToken]. What specific risk does this attribute mitigate?

a)

SQL injection in queries

b)

Cross-Site Scripting payloads

c)

Cross-Site Request Forgery attacks

d)

Man-in-the-middle interception

121.

In an ASP.NET Core MVC controller, which condition should typically short-circuit a POST action to redisplay the view with user input?

a)

ViewData count is zero

b)

HttpContext.Request.IsHttps

c)

User.Identity.IsAuthenticated

d)

ModelState.IsValid is false

122.

Given an EF Core repository method that returns await _context.Obstacles.Include(o => o.Report).FirstOrDefaultAsync(o => o.Id == id); what does Include(o => o.Report) achieve?

a)

Filters rows by Report fields

b)

Eager loads related Report entity

c)

Defers loading until first access

d)

Creates a database transaction scope

123.

Which statement best describes FirstOrDefaultAsync with a predicate like o => o.Id == id in EF Core?

a)

Blocks the thread until completion

b)

Returns all matching entities in a list

c)

Always throws if no entity exists

d)

Returns the first matching entity or null

124.

You must design a Login POST action. Which minimal set of attributes and checks aligns with secure and validated submission in ASP.NET Core MVC?

a)

[HttpPost] only, rely on client-side checks

b)

[AcceptVerbs("POST","PUT")], skip validation

c)

[HttpGet] and [Authorize], ignore ModelState

d)

[HttpPost] and [ValidateAntiForgeryToken], check ModelState

125.

When using a repository in a controller, which code pattern correctly applies Dependency Injection for the repository field?

a)

Repository created with ActivatorUtilities each call

b)

Public settable field, modified in Startup

c)

Static repository instance, newed inside action

d)

Private readonly interface field, assigned via constructor