asp.net MVC RenderAction 协调器

发布于 2024-08-15 18:55:55 字数 182 浏览 8 评论 0原文

我们正在研究 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半葬歌 2024-08-22 18:55:55

使用 Html.RenderPartial() 代替

您在这里问的基本上是您使用 MVC 1 中旧的好的 RenderPartial 实现的功能。通过一个操作加载所有数据而不是渲染部分视图而不是控制器检查其数据是否已加载。

在您的特定情况下,您的控制器必须做的是检查它将要渲染哪个视图,然后解析其内容以查看将调用哪些控制器并执行此操作。我认为这无论以何种方式或形式都是不可行的。在这种特殊情况下,您搞乱了关注点分离,因为您将两者绑定在一起。

也许可以向我们提供有关您实际遇到的问题的更多具体信息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文