问题描述
我想了解的RenderPartial和的RenderAction之间的差异。我想这是的RenderPartial像一个用户控件并且是的RenderAction像一个服务器端包含。有人可以把这个观点,请有可能的话给我的每个将用于一对夫妇的情景?
I am trying to understand the difference between a RenderPartial and RenderAction. I guess that RenderPartial is like a UserControl and RenderAction is like a server-side include. Can someone put this in perspective please and if possible give me a couple scenarios of where each would be used?
推荐答案
你见过的?
摘要:
- 的RenderPartial:你是负责提供一个模型,执行逻辑等
- 的RenderAction:你是负责调用一个动作,该控制器负责提供一个模型,执行逻辑等 。
此外,会的RenderPartial呈现一个特别的景观,可以的RenderAction呈现它想要的任何视图,它给控制器。例如:显示与登录信息的查看时,你是客人(未通过身份验证),当你进行身份验证以普通用户一种观点认为,一查看,当你是一个管理员可能会返回一个视图的操作。你作为的的RenderAction调用者不必在所有关心,你刚才叫你的行动
Furthermore, RenderPartial will render a particular View, RenderAction can render any View it want, it's up to the controller. For example: an action that displays a View with login information might return one view when you are a guest (not authenticated), one View when you are authenticated as a regular user, and one View when you are an admin. You, as the caller of RenderAction don't have to care at all, you just call your action
这篇关于ASP.NET MVC 2.0 - 的RenderPartial和之间的RenderAction差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!