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?
Asked
Active
Viewed 57 times
1 Answers
4
Use @{ Html.RenderAction("TagCloud", "SomeController"); }
.
public class SomeController : Controller {
public ActionResult TagCloud() {
var model = // fetch data for tagcloud
return View("~/Views/Shared/Tagcloud.ascx", model);
}
}
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.

Jan Jongboom
- 26,598
- 9
- 83
- 120
-
Hmmmm, that looks like it just might work. Thanks, let me try it. – Darthg8r Sep 07 '11 at 16:53