Join Jess Chadwick for an in-depth discussion in this video Reuse application features with view components, part 2, part of Learning ASP.NET Core MVC.
- [Instructor] Perhaps the best use of a view component…is to have it retrieve its own data…so that views can render it…without having to know or care where that data comes from.…For instance, in this example,…the monthly specials section…contains a list of the monthly specials…available on the site.…This is currently static html…but I'm going to create a class…that provides the same information as raw data…for the view component to retrieve.…Just a warning, it's going to be big.…But you can copy and paste it…from the files in your courseware.…
This new specials data context class…contains a method that returns an array of special objects.…It just so happens that I've hard coded the data here…but this could be coming from anywhere,…such as a database or a web service.…Now that I have this class in place,…I can use the built-in dependency injection…to inject it into the constructor of my view component…like so.…And, as I've showed several times already,…in order to get dependency injection to work,…I've got to register this dependency in my startup class.…
- Building blocks of ASP.NET Core applications
- Creating a new project
- Responding to HTTP requests
- Serving static files
- Understanding the MVC pattern
- Handling requests with controllers
- Rendering HTML with Razor
- Rendering data, view markup, and view logic
- Creating HTML forms
- Validating form data
- Reading and writing from a database with Entity Framework
- Improving the user experience
- Exposing data with a web API
- Securing your ASP.NET application
Skill Level Intermediate
1. The Basics
2. The Model-View-Controller (MVC) Pattern
Understand routing4m 24s
3. Render HTML with Views
4. Work with Data
5. Improve User Experience with Ajax and Web APIs
6. Secure Your Application
Next steps1m 42s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.