ASP.NET Core MVC View Components

China☆狼群 提交于 2019-12-10 01:29:03

问题


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.


回答1:


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:

  • Exciting Things About ASP.NET vNext Series: MVC View Components

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




回答2:


Currently there is available a brand new documentation from Microsoft:

  • View Components documentation.


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.



来源:https://stackoverflow.com/questions/26989320/asp-net-core-mvc-view-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!