Develop the UX Flashcards
SEO, global and localization strategies
asp-action
tag helper that tells Razor what controller action we want to use on submit
asp-controller
tag helper to let our form know which controller to find the action in
ApplicationDbContext
provides the context to interface with the database and is referenced in the models
DbContext
Within ApplicationDbContext and teaches entity framework how the database will work
DbSet
a collection that represents an individual database table or view
private readonly ApplicationDbContext _context;
public AController(ApplicationDbContext Context)
allows for the same instance of the DbContext to be used instead of being created each time we request it
Inversion of Control
allows us to loosen the coupling of dependencies
_context.SaveChanges()
required to actually push the changes to the database (can do multiple then call)
startup.cs
configure the application and let it know what is is going to use
asp-for=”Name”
Tag helper - will populate the label with a field’s Name and also set the type, id, and name attributes on an input field
[Display(Name = “Name with Space”)]
Data Annotation - sets the display name which gets passed asp-for what you want the label to be
_ViewStart.cshtml
allows us to set code that applies when you return a view:
@{ Layout = “_Layout”; }
@ViewData
is a dictionary that allows us to pass data from our controller to our view
@RenderSection
acts as a placeholder to pass specific content into the page (can be set as required or optional)
@RenderBody
where all content not set to a specific section will be rendered
@section
will match up with any RenderSection with a matching name and replace it with its content
Partial views
can be used for duplicate formatting that is applied multiple times to reduce repeat code
@Html.EditorForModel()
automatically creates labels and input fields in this form based on properties in the model
Shared/EditorTemplates
Folder to hold field overrides that Razor uses to auto-generate fields
Application wide route formatting
do within the startup.cs
routing for specific actions
do within the select controller
[Route(“”)]
set a custom route for a given action
[HttpGet]
specify for an action to only allow a GET request
[Key]
Data Annotation - to make sure field is unique
[Required]
Data Annotation - makes field non-nullable
[MinLength(3)]
Data Annotation - makes field have a minimum length
asp-validation-summary=”All”
used to display errors for the given model and will include all, not just a specific field
ModelState.IsValid
checks the current state of the model and can be referenced to handle errors (auto populates asp-validation-summary)
ModelState.AddModelError(“A”, “B”)
manually adds an error for the given field name (A) and the appropriate error message to display (B)
[A(ErrorMessage = “B”)]
Data Annotation - For a given rule (A) set a more semantic error message (B)
_ViewImports
Way to add things that will appear on every page (usually @using statements such as controllers)
@addTagHelper *, A
_ViewImports component that brings in the most recent version of the associated tag helper library (A)
[HttpGet(“A”)]
Can change the routing for a given action to specify the desired URL (A)
asp-validation-for=”A”
tag helper to display an error for a specific field (A)