什么是MVC子操作? [英] What is an MVC child action?

查看:75
本文介绍了什么是MVC子操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到的MVC(基波书)孩子的行为,但我真的不知道它是什么?

I read about child actions in MVC (fundamental book), but I don't really know what it is?

能否有人请解释一下这些方法?

Could some one please explain these methods?

推荐答案

菲尔哈克解释它在很好的这个博客帖子。基本上一个孩子的动作是,你可以从视图中使用 Html.Action 帮助调用控制器动作:

Phil Haack explains it nicely in this blog post. Basically a child action is a controller action that you could invoke from the view using the Html.Action helper:

@Html.Action("SomeActionName", "SomeController")

这个动作将执行,并在视图中的指定位置提供它的输出。用部分不同的是,一个局部仅包括特定的标记,没有超过的主要动作执行其他动作。

This action will then execute and render its output at the specified location in the view. The difference with a Partial is that a partial only includes the specified markup, there's no other action executing than the main action.

所以你基本上接收请求和呈现的观点,但在该视图中,你可以渲染将通过其独立MVC的生命周期,最终使输出多个子行动的主要动作。而这一切会发生在一个单一的HTTP请求的情况下。

So you basically have the main action which received the request and rendered a view, but from within this view you could render multiple child actions which will go through their independent MVC lifecycle and eventually render the output. And all this will happen in the context of a single HTTP request.

儿童行动是创造它可以被嵌入到你的意见,并通过他们的独立MVC生命周期的哪去了整个部件可重复使用的有用的。

Child actions are useful for creating entire reusable widgets which could be embedded into your views and which go through their independent MVC lifecycle.

这篇关于什么是MVC子操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆