Design the App Architecture Flashcards
app.UseStaticFiles()
Startup.cs - defaults to serving files from the wwwroot folder by default
app.UseDefaultFiles()
look for blank directory URL as a file and changes the app to understand as file references (not required if MVC is enabled)
app.UseDeveloperExceptionPage()
Startup.cs - want to support pages being shown when exceptions are thrown, not “file not found”, and present the actual stack trace
services.AddTransient
startup.cs - service that is kept for the length of the request (no data associated, mostly helper functions)
services.AddScoped
startup.cs - service that is kept for the length of a connection (database oriented work)
services.AddSingleton
startup.cs - services that are created once and used for lifetime of web app
steps for adding a service
1 create the class 2 extract / create the interface 3 load the service in startup.cs 4 pass into the given controller / model
dotnet ef database update
run initialization command to setup database to use EF (only provisions the migrationsHistory table
dotnet ef migrations add
Looks at the data stores we have and adds code that lets us go from current DB state to new DB state (DOES NOT ACTUALLY PROVISION TABLES)
_ctx.SaveChanges()
returns the number of rows affected / that are different from the DB state
[Authorize]
Route parameter that says that some type of authorization has to happen to navigate there
services.AddIdentity<a></a>
startup.cs configure identity for given class (A) and provide it an instance of the IdentityRole (B)
.AddEntityFrameworkStores<a>();</a>
Letting EF know what type of context to use (A) for when EF wants to access data in the database
app.UseAuthentication();
startup - configure() - tells the app that we want to use authentication and use any config done in config services
signInManager.PasswordSignInAsync
attempts to sign in using the username and password instead of having to go and get the stored object