ASP Flashcards
HTML Helpers like @Html… are replaced by what in Core
Tag Helpers
How do you set up Dependency Injection?
there is a ConfigureServices method in the startup.cs class - this is where DI can be set up. Use the services.AddTransient();
There are two special views by default in the Views folder - what are these?
there is a _ViewStart.cshtml file in the main Views folder - anything in this file will be first added to the top of each view when rendered. And there is a _ViewImports.cshtml file in the main Views folder - anything in this file will be added as Imports to all views
In Core, which of these can you use: model first, code first, database first
Only code-first
Why use a “virtual” property on a model when using Entity Framework?
in EF, virtual on a model property makes this lazy-loaded; you can always remove virtual and make the property eager-loaded
Where are connection strings defined in Core?
in core, the connection strings should be in appsettings.json (rather than web.config)
Are configuration settings mainly defined in Web.config in ASP.Net Core?
No - the config.json file is generally not used in Core.
Where are client-side (static) files defined in an ASP.Net Core app?
In Core, there is a wwwroot folder which should hold all static files (JS, CSS, etc)
In a view, how can you conditionally include html when in dev mode?
You can use to include/exclude content in razor views depending on the environment setting
How do view components differ from partial views?
View components - like partial views but allows access to data from view; can have more logic; must be used from view ( partial can be used as stand alone view); you create class and a view for the component - so more code oriented
What data annotation can you use to specify a property of a model should never be sent back when model is bound in a form?
[BindNever]
On a form, how can you add a section to show all input errors together?
Add a div with tag helper of asp-validation-summary=”All”
On a form, how can you add a section to show oneinput field’s error?
Add a span or div with tag helper of asp-validation-for=””
In which method do you add functions to the ASP pipeline?
In the Configure method of the Startup class.
In which method do you defined elements for dependency injection?
In the ConfigureServices method of the Startup class