General Flashcards
You want to disable your application from launching on the browser as soon as you run the project. You want to change the port as well. In what file is this possible?
LaunchSettings.json. Port changes are inside the IIS settings and launchBrowser within profiles.
What is the name of the file where you set configuration values for the app?
appsettings.json
How can you set different configurations for different environments?
Create additional appsettings files, suffixed with ‘.Development’ and ‘.Production’ .json.
What’s the name of the interface you use to retrieve values in appsettings.json?
Iconfiguration
What is the method used to retrieve a section from appsettings.json?
configuration.GetSection(“sectionName”);
What is the entry point of every ASP.NET Core Web API application?
Program.cs
What is the name of file that allows configuration of the services and middleware used in the API?
startup.cs
What methods exist in the startup.cs file, and what is their purpose?
ConfigureServices Method: configure the services used within the app.
Configure method: Configuration of the app’s middleware pipeline
How can you extend an objects behavior, besides inheritance?
Create an extension method.
How do you create an extension method?
Create a new static class and within, the static method that will extend the behavior of the desired object. This method will have ‘this’ as its first parameter together with the type that will be extended.
what are the three ways to register services in ASP.NET Core in the IoC container?
AddSingleton, AddScoped, AddTransient
What does services.AddSingleton do?
Creates a service once and provides the same instance for each subsequent call.
What does services.AddScoped do?
Creates a new service for each Http request.
What does services.AddTransient do?
Creates a new service every single time it’s requested.
What is the purpose of models / entities in Entity Framework Core?
They are classes that represent the table structure of the database, with properties that are used in the construction of the columns and defining the relationship with other models.