Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top