公共内容部分视图
我有一个标签云,我将其包含在我网站上的几乎所有视图中。我意识到我可以把它放在主页上。更大的问题是,如何将数据库中的数据传递给它?我想避免必须在每个控制器和操作中获取数据。有没有简单的方法可以做到这一点?
I have a tag cloud that I'm including on nearly all of the views that I have in my site. I realize that I can put it on a master page. The bigger question is, how do I pass it the data from the database? I'd like to avoid having to fetch the data in every single controller and action. Is there an easy way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
@{ Html.RenderAction("TagCloud", "SomeController"); }
。加载具有自己的视图模型的视图是很常见的,因为它在许多不同的页面和场景之间共享,在它自己的操作中。
Use
@{ Html.RenderAction("TagCloud", "SomeController"); }
.It's quite common to load a view that has it's own view model, f.e. because it's shared among a lot of different pages and scenario's, in it's own action.