What is the name of the Microsoft build engine?
Front
Active users
38
All-time users
43
Favorites
1
Last updated
5 years ago
Date created
Jun 29, 2020
Unsectioned
(167 cards)
What is the name of the Microsoft build engine?
MSBuild
Where is the runtime environment for ASP.NET Core set?
In the Properties/launchSettings.json file. (ASPNETCORE_ENVIRONMENT variable)
Which middleware method adds a simple message to HTTP responses that would not otherwise have a body (such as 404 - Not Found responses)?
app.UseStatusCodePages()
Which IApplicationBuilder method is used to add a class-based custom middleware component to the request pipeline?
app.UseMiddleware<CustomMiddlewareClassName>();
Which HttpContext property returns an HttpResponse object that is used to create a response to the HTTP request?
HttpContext.Response
Which HttpContext property returns a ConnectionInfo object that provides information about the network connection underlying the HTTP request, including details of local and remote IP addresses and ports?
HttpContext.Connection
CLI command to execute the commands in an Entity Framework database migration, thereby updating the database?
dotnet ef database update
Which method adds a middleware component that displays details of unhandled exceptions (usually for use in dev environments)?
app.UseDeveloperExceptionPage()
Which project folder (hidden by Visual Studio by default) contains the intermediate output from the compiler?
/obj
What are the necessary elements of an Extension Method?
What does the HttpResponse.WriteAsync(data) method do?
It writes a data string to the response body
What does the acronym JSON stand for?
JavaScript Object Notation
Which async method on the HttpResponse object enables you to write a data string to the response body?
HttpResponse.WriteAsync(data)
Since Tag Helpers can't be discovered automatically (unlike controllers and view), where can they be registered?
_ViewImports.cshtml
What HttpContext property provides access to the services available for the request?
HttpContext.RequestServices
What does the HttpContext.Features property provide access to?
Request features, which allows access to the low-level aspects of request handling.
How does the ASP.NET Core routing system decide which route to select if there are multiple matches?
Each matching route is given a score and the route with the lowest score is selected. In general, the most specific route receives the request. Literal Segments before Segment Variables, and Segment Variables with constraints before those without. If two routes have the same score, then an Ambiguous Routing error is thrown.
Which HttpRequest property returns a stream that can be used to read the request body?
HttpRequest.Body
In ASP.NET Core routing, what are Fallback Routes, and which method is used to create them?
Fallback Routes are routes that direct a request to an endpoint only when no other route matches a request. They prevent requests from being passed further along the request pipeline by ensuring that the routing system will always generate a response. They are created with the MapFallback
method.
Ex:
endpoints.MapFallback(async context => {
await context.Response.WriteAsync("Routed to fallback endpoint");
});
CLI command for installing tools
dotnet tool
What does the HttpContext.RequestServices property provide access to?
The services available for the request
When adding a custom middleware component in ASP.NET Core, why might you want to use a class instead of a lambda function?
Using lambda functions is convenient, but it can lead to a long and complex Configure method in Startup. Also, using a class enables reuse of the custom middleware component across different projects.
Which HttpRequest property returns the path section of the request URL?
HttpRequest.Path
How do you set the status code for the HTTP response in ASP.NET Core?
HttpResponse.StatusCode
What does the HttpContext.Response property return?
An HttpResponse object that is used to create a response to the HTTP request.
Where is the cache created by AddDistributedMemoryCache stored?
In memory as a part of the ASP.NET Core process, which means that applications that run on multiple servers or containers don't share cached data. It also means the contents of the cache are lost when ASP.NET Core is stopped.
The User property which describes the user associated with the current request is a member of which class?
ControllerBase
Which class is responsible for configuring an ASP.NET Core application?
The Startup class
ASP.NET automatically maps requests for static content (images, CSS, JS) to which folder?
wwwroot
What does it mean if an ASP.NET Core middleware component short-circuits the pipeline?
The middleware component has chosen not to call the next function, so the request isn't passed on.
Which HttpResponse property returns true if ASP.NET Core has started to send the response headers to the client (after which it is not possible to make changes)?
HttpResponse.HasStarted
Which tag helper is applied to a div to show a list of validation errors?
asp-validation-summary
What is the name of the class associated with a Razor Page?
The page model class (myPage.cshtml.cs)
What is the syntax for the Null Conditional Operator
?. (e.g. myObject?.myProperty)
Which IApplicationBuilder method registers a middleware component? (Typically expressed as a lambda function that receives each request as it passes through the request pipeline.)
app.Use(async (context, next) =>
In ASP.NET Core, when is a URL considered a match for a URL Pattern in a route definition?
What are the two methods included in Startup.cs by default?
ConfigureServices
Configure
What does Visual Studio use instead of the built-in ASP.NET Core HTTP Server?
Visual Studio uses IIS Express as a reverse proxy for the built-in ASP.NET Core HTTP server (Kestral).
How many bits in a byte?
8 bits in a byte
What is the Visual Studio hotkey to start without debugging
Ctrl-F5
What is the name of the HTTP server that ASP.NET Core uses?
Kestral
How can you tell if a request was made using HTTPS in ASP.NET Core?
The HttpRequest.IsHttps property
In ASP.NET Core, what is the purpose of the Host?
The host encapsulates all of the app's resources, such as:
Which HttpContext property returns the session data associated with the request?
HttpContext.Session
To what does ASP.NET Core delegate the the work of receiving and responding to HTTP requests?
To middleware components which are arranged in a chain known as the request pipeline.
CLI command for creating an Entity Framework migration?
dotnet ef migrations add {migrationName}
Which method in the Startup class is used to register the middleware components for the request pipeline?
The Configure method
In ASP.NET Core routing, what's another term for route parameters?
Segment Variables
When is a new instance of the Controller class created? (i.e. What is its scope?)
A new instance of the controller class is created every time one of its actions is used to handle a request.
In ASP.NET Core, what system is responsible for selecting the endpoint that will handle an HTTP request?
The Routing System
Which file is the entry point for the ASP.NET Core platform?
Program.cs
Any class can be used as a service, and there are no restrictions on the features a service can provide, so what makes services special?
They are managed by ASP.NET Core, and dependency injection makes it possible to access services anywhere in the application, including in middleware components.
What HttpContext property returns an HttpRequest object that describes the HTTP request being processed?
HttpContext.Request
What could you use to add a method to a class that you cannot modify directly?
An Extension Method
Which project file is used to select a specific version of the .NET Core SDK?
global.json
What is the collective term for objects returned from Action Methods. (e.g. ViewResult, RedirectResult, HttpUnauthorizedResult)
Action Results
For which process is the XML describing a project in the .csproj file primarily for?
MSBuild
How can you access the request cookies in ASP.NET Core?
The Cookies property of the HttpRequest and HttpResponse objects
Usage:
context.Request.Cookies.Append("key", "value")
context.Request.Cookies["key"]
context.Response.Cookies.Delete("key")
What is a delegate?
A type that represents references to methods with a particular parameter list and return type. Delegates are used to pass methods as arguments to other methods.
What is an Extension Method?
A way to add methods to classes that you cannot modify directly.
Which HttpRequest property returns the query string section of the request URL as key/value pairs?
HttpRequest.Query
In ASP.NET Core, what does the Append method of HttpResponse.Cookies do?
Creates or replaces a cookie in the response.
Usage:
context.Response.Cookies.Append("name", "value",
new CookieOptions { ... })
CLI Item template to create a solution file.
dotnet new sln -o MySolution
Which common pattern in ASP.NET Core is used to ensure exception handling middleware is only added to Development and HSTS middleware is only added outside of development?
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
} else {
app.UseHsts();
}
Which HTTP method is used to update part of an existing object?
PATCH
What is a "route"?
A rule that is used to decide how a request is handled.
CLI command to create a project
dotnet new
In ASP.NET Core routing, how are optional segments used and denoted?
Optional segments allow the route to match URLs that don't have a corresponding path segment. They are denoted with a question mark.
Ex: endpoints.MapGet("size/{city?},
...
What two things does the ASP.NET Core Routing System do?
Which interface provides access to URL-generating functionality?
IUrlHelper
Where is Startup.cs configured to be the next step in the startup process (after Main)?
In the CreateHostBuilder method of Program.cs.
CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseStartup<Startup>();
});
CLI command to build and run a project
dotnet run (dotnet build just builds it)
Which keyword does pattern matching (to test that an object is of a specific type or has specific characteristics)?
is
(e.g. if( data[i] is decimal d) )
Other than the VS NuGet Package Manager, what other package manager is there?
The Client-Side Library Manager (for things like Bootstrap)
What does the HttpContext.Request property return?
An HttpRequest object that describes the HTTP request being processed
Which project folder (hidden by Visual Studio by default) contains the compiled application files?
/bin
What happens if no response is generated by the middleware components in ASP.NET Core's request pipeline?
ASP.NET Core will return a response with the HTTP 404 Not Found status code.
Which statement in the Configure method of the Startup class in an ASP.NET Core project adds support for responding to HTTP requests with static content?
app.UseStaticFiles
What is the ASP.NET Core dependency injection feature used for?
For creating and consuming services, and makes it easy to create the components in a loosely-coupled way.
Which middleware method enables support for serving static content from the wwwroot folder?
app.UseStaticFiles()
What does the HttpContext.Session property return?
The session data associated with the request
Which HTTP Method is used to update an existing object?
PUT
What does the HttpResponse.HasStarted property tell you?
It returns true if ASP.NET Core has started to send the response headers to the client, after which it is not possible to make changes.
In an ASP.NET Core application, what is the term for the thing that handles incoming requests?
An Endpoint
Which two method calls must be added to the ASP.NET Core Startup class to use MVC?
services.AddControllers()
in ConfigureServices
endpoints.MapControllers()
in the UseEndpoints method of Configure
In ASP.NET, what is an Endpoint?
The thing that handles incoming requests.
In ASP.NET Core routing, how are default value for segment variables used?
The default values are used when the URL doesn't contain a value for the corresponding segment. This increases the range of URLs that the route can match.
Ex: endpoints.MapGet("capital/{country=France}",
...
In ASP.NET, what is the term for a rule that is used to decide how a request is handled?
A route
What property is provided by the Controller Base Class to provide details of the outcome of the Model Binding process?
ModelState
CLI command to list the packages installed in a project?
dotnet list package
What does TLS stand for?
Transport Layer Security
(It replaces the obsolete SSL protocol, even though the term "SSL" has become synonymous with secure networking and is often used when TLS is actually being used.)
What does ASP.NET Core do with the HTTP requests it receives?
It passes them along a request pipeline (which is populated with middleware components).
What two objects does the ASP.NET Core platform create when a new HTTP request arrives?
An object that describes the request and a corresponding object describing the response that will be sent in return. These objects are passed to the first middleware component which inspects the request, modifies the response, and passes them on to the next middleware component in the chain. Once the request has made its way through the pipeline, the ASP.NET Core platform sends the response.
What is the primary purpose of the ASP.NET Core platform?
To receive HTTP requests and send responses to them.
What is the purpose of the ActivatorUtilities class (defined in the Microsoft.Extensions.DependencyInjection namespace)?
It provides methods for instantiating classes that have dependencies declared through their constructor.
Ex:
CreateInstance<T>(services, args)
GetServiceOrCreateInstance<T>(services, args)
Which file (hidden by Visual Studio by default) is used to configure the ASP.NET Core application when it starts?
Properties/launchSettings.json
Where is the ModelState property defined?
In the Controller Base Class
On which port does the integrated ASP.NET Core HTTP server listen?
5000
In ASP.NET Core routing, how are constraints on segment matches denoted?
With a colon. They can also be combined.
Examples:
{first:int}/{second:bool}/{third:alpha}
{first:alpha:length(3)}/{second:regex(^uk|france|monaco$)}
Why is it preferable to use Tag Helpers rather than including blocks of C# code in a view?
Because Tag Helpers can be easily unit tested.
Where are the request pipeline middleware components registered?
In the Configure method of the Startup class
What are Action Results?
The collective term for objects returned from Action Methods. (e.g. ViewResult, RedirectResult, HttpUnauthorizedResult)
How does the Session Cookie work in ASP.NET Core?
When a request containing a Session Cookie is received, the session middleware component retrieves the server-side data associated with the session and makes it available through the HttpContext object.
In ASP.NET which ControllerBase property returns the data extracted from the request url by the routing middleware?
RouteData
CLI command to add packages to a project
dotnet add package
Which file is used to configure the ASP.NET Core runtime and its associated frameworks?
Startup.cs
In which folder should Views for components be located (by convention)?
Views/Shared/Components/{Component Name}/
What does the HttpRequest.ContentType property return?
The value of the Content-Type header
Can middleware components be configured?
Yes. A common pattern for this is the options pattern which defines a class containing config options and uses the IOptions<T> parameter of the Startup.Configure method.
Which startup method in ASP.NET Core provides the configuration for the endpoint routing middleware added by the UseRouting method?
app.UseEndpoints()
What does the HttpRequest.Form property do?
Returns a representation of the request body as a form.
Which HttpRequest property returns the verb used for the request?
HttpRequest.Method
In which file (hidden by Visual Studio by default) includes package dependencies and build instructions?
the .csproj file
What HttpRequest property returns the value of the Content-Type header?
HttpRequest.ContentType
What does the HttpRequest.Query property return?
The query string section of the request URL as key/value pairs
In ASP.NET Core, how can cookies be configured when they are created with the Append method?
By using the CookieOptions argument.
(ex. Expires, MaxAge, Path, Secure, etc.)
Item template to add a global.json file to a project, specifying the version of .NET Core that will be used
dotnet new globaljson --sdk-version 3.1.101 --output MySolution/MyProject
How do you read aloud the lamba expression character => ?
"goes to"
In ASP.NET Core, why might using Session to maintain application state data be preferable to using cookies?
Cookies are stored at the client where it can be manipulated and used to alter the behavior of the application.
Project template for ASP.NET Core project configured to use the MVC Framework
dotnet new mvc
What does the acronym REST stand for?
Representational State Transfer
What does the HttpContext.User property return?
Details of the user associated with the request
Project template for ASP.NET Core project configured to use Razor Pages
dotnet new webapp
What is the HSTS protocol?
HTTP Strict Transport Security
This includes a header in responses telling browsers to only use HTTPS when sending requests to the host, even if the user specifies HTTP.
How can you access request headers in ASP.NET Core?
The HttpRequest.Headers property
What does ASP.NET Core call the sections of a URL path separated by the "/" character?
Segments
CLI command for managing client-side packages
libman
CLI command to remove a package from a project?
dotnet remove package
In ASP.NET Core routing, must segment variables always be separated by the "/" character?
No, they can be separated by any static string.
Ex: endpoints.MapGet("files/{filename}.{ext}"...
What are the two ways to add a custom middleware component in ASP.NET Core?
You can use a lambda function (anonymous method?) or a class file.
In ASP.NET Core, what is the difference between middleware components that use next()
to invoke the next component in the pipeline, and those that use next.Invoke()
?
They are equivalent. Next()
is provided by the compiler as a convenience.
Which ASP.NET Core object describes the HTTP request and response, and provides additional context including details of the user associated with the request?
Microsoft.AspNetCore.Http.HttpContext
What is the syntax for Automatically Implemented Properties?
public string Name {get; set;}
Same as:
public string Name{
get { return name; }
set { name = value; }
}
Which startup method in ASP.NET Core adds the endpoint routing middleware component to the pipeline?
app.UseRouting()
What is the difference between a (forward) proxy and a reverse proxy?
A forward proxy proxies in behalf of clients (or requesting hosts), a reverse proxy proxies in behalf of servers
What does the HttpRequest.Path property return?
The path section of the request URL
CLI commands to add a new project to a solution
dotnet sln MySolution add MySolution/MyProject
What does the HttpRequest.ContentLength property return?
The value of the Content-Length header
Which ASP.NET Core middleware component enforces the use of HTTPS?
app.UseHttpsRedirection()
which generally appears near the start of the request pipeline so that redirection to HTTPS occurs before any other component can short-circuit the pipeline and produce a response using regular HTTP.
What is a reverse proxy?
A reverse proxy is a type of proxy server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client, appearing as if they originated from the proxy server itself.
Which file keeps track of the packages added to a project?
The Project (.csproj) file
Which two methods add the routing middleware in ASP.NET Core?
UseRouting
UseEndpoints
What does the HttpContext.Connection property return?
A ConnectionInfo object that provides information about the network connection underlying the HTTP request, including details of local and remote IP addresses and ports.
What does the IApplicationBuilder method UseEndpoints
do?
It defines the routes that match URLs to endpoints.
What are ASP.NET Core View Components?
A C# class that provides a small amount of reusable application logic with the ability to select and display Razor partial views.
Which method in Program.cs is invoked when the application is executed (and is known as the application's entry point)?
public static void Main(string[] args)
Which Bootstrap class centers the contents of an element and its children?
text-center
What is the difference between ASP.NET Core Views with names that begin with underscores and those that don't?
Views with names that begin with an underscore are not returned to the user, which allows the file name to differentiate between views that you want to render and the files that support them.
Can the ASP.NET Core request pipeline be branched?
Yes, using the IApplicationBuilder methods Map
(or MapWhen
if you want to use a predicate other than just URL-based conditions)
Which HttpContext property returns details of the user assocated with the request?
HttpContext.User
In ASP.NET Core, upon startup, what does the Main method build?
A host
Which HttpContext property provides access to request features, which allow access to the low-level aspects of request handling?
HttpContext.Features
What does the IApplicationBuilder method UseRouting
do?
It adds the middleware responsible for processing requests to the pipeline.
What happens to the request pipeline in ASP.NET Core when a route matches a URL?
The pipeline is short-circuited. The request isn't forwarded to other endpoints or middleware components that appear later in the request pipeline.
Which method of a view component is called when the component is used in a Razor view?
Invoke()
In ASP.NET Core, what is a Catchall Segment Variable used for and how is it denoted?
It allows routes to match URLs that contain more segments than the pattern. It is denoted with an asterisk before the variable name.
Ex: endpoints.MapGet("{first}/{second}/{*catchall}",
...
Project template for ASP.NET Core project configured to use Blazor Server
dotnet new blazorserver
What does the Bootstrap class text-center do?
Centers the contents of an element and its children
What is the purpose of a Razor Page's page model class?
It defines handler methods that are invoked for different types of HTTP requests which update state before rendering the view.
What does the HttpRequest.Method property return?
The verb used for the request
Project template with minimum code and content required for ASP.NET Core development
dotnet new web
What does the HttpRequest.Body property return?
A stream that can be used to read the request body
What HttpRequest property returns the value of the Content-Length header?
HttpRequest.ContentLength
In ASP.NET Core, what do you call URL routing segments that match requests using fixed strings (rather than Segment Variables)?
Literal Segments (or Static Segments)
What is the main source of configuration data in ASP.NET Core?
The appsettings.json file
What is the syntax for the Null Coalescing Operator?
?? (e.g var name = p?.Name ?? "<None>";)
In ASP.NET Core's Dependency Injection, what can be used to strike a balance between Singleton Services and Transient Services?
Scoped Services, which shares a resolved service object between all the components handling a single HTTP request.