24 Using view components

This chapter covers

  • Using view components to generate content that is orthogonal to the main purpose of the application
  • Applying view components in views
  • Passing data to view components from the parent view
  • Using partial views to generate HTML content
  • Creating classes that are controllers and view components

I describe view components in this chapter, which are classes that provide action-style logic to support partial views; this means view components provide complex content to be embedded in views while allowing the C# code that supports it to be easily maintained. Table 24.1 puts view components in context.

Table 24.1 Putting view components in context

Question

Answer

What are they?

View components ...

Get Pro ASP.NET Core 7, Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.