asp.net MVC RenderAction 协调器
我们正在研究 ASP.NET MVC 2 beta RenderAction() 方法。我们非常喜欢它,但似乎我们不能使用异步控制器。有谁有一个“控制器”的例子,它可以计算出将被调用的所有操作,缓存数据,然后让被调用的操作知道它们的数据已经存在,而不是必须调用才能获取它?
此处已发布的大多数问题都引用了 MVC 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
Html.RenderPartial()
代替您在这里问的基本上是您使用 MVC 1 中旧的好的
RenderPartial
实现的功能。通过一个操作加载所有数据而不是渲染部分视图而不是控制器检查其数据是否已加载。在您的特定情况下,您的控制器必须做的是检查它将要渲染哪个视图,然后解析其内容以查看将调用哪些控制器并执行此操作。我认为这无论以何种方式或形式都是不可行的。在这种特殊情况下,您搞乱了关注点分离,因为您将两者绑定在一起。
也许可以向我们提供有关您实际遇到的问题的更多具体信息。
Use
Html.RenderPartial()
insteadWhat 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.