Tim
Tim

Reputation: 7421

ASP.NET Core MVC View Components

In ASP.NET Core MVC (formerly MVC 6) there is a new area of functionality called View Components which appear to be a better alternative to Partial Views. I've seen the following View Component Example. But there doesn't seem much more information currently as to their usage.

I'm trying to evaluate if its worth using this pattern and if this can/(or is intended) to be used as a more baked in method to help with donut caching.

Upvotes: 15

Views: 6248

Answers (2)

Lukasz Mk
Lukasz Mk

Reputation: 7350

Currently there is available a brand new documentation from Microsoft:


In my opinion ViewComponents are very useful and flexible features. I like them, and I can recommend them.

However not always View Component is "a better alternative to Partial Views" - this will depend on your particular case.

Upvotes: 1

tugberk
tugberk

Reputation: 58434

View components are definitively great and it's certainly an improvement. The one big improvement is that you can run asynchronous operations on view components where it wasn't possible with child actions.

More information available here:

For donut caching, there are two separate issues filed that you can comment/track: #1232 and #536

Upvotes: 10

Related Questions