views:

82

answers:

1

We're looking at the ASP.NET MVC 2 beta RenderAction() method. We like it very much but it seems that we can't use async controllers with it. Does anyone have an example of a "controller" that can figure out all the actions that will be called, cache the data, then let the called actions know that their data already exists vs. having to call to get it?

Most of the q's already posted here reference the MVC 1 or earlier previews.

A: 

Use Html.RenderPartial() instead

What you're asking here is basically the functionality you'd implement using the old good RenderPartial from MVC 1. Have one action load all data and than rendering partial views instead of controllers checking whether their data is already loaded or not.

And in your particular case what your controller would have to do is to check which view it's goging to render, then parse its content to see which controllers will be called and do that. I don't think that would be feasible in any way shape or form. You're messing with separation of concerns in this particular case, because you're bounding the two together.

Maybe enlighten us with a bit more specifics about the problem that you're actually having.

Robert Koritnik
This might be a good idea. Think of your favorite portal site that shows you content based on what you seem to like. If you click on a lot of stories about Tony Romo, we'll prefer those stories when you visit the site. Maybe we'll also show you NFL stories next to it. Conversely if you follow Politics we'll show you that. All this while showing you relevant ads of course. I already have a pretty good model but perhaps tweaking it to use RenderPartial will be more feasible. Regardless, there's a master controller that figures out what data to retrieve.
No Refunds No Returns