Html.Partial VS Html.RenderPartial&安培; Html.Action VS Html.RenderAction。任何一个可以请描述的区别 [英] Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction. can any one please describe the difference

查看:144
本文介绍了Html.Partial VS Html.RenderPartial&安培; Html.Action VS Html.RenderAction。任何一个可以请描述的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.NET MVC,之间有什么区别:

  Html.Partial和Html.RenderPartial
Html.Action和Html.RenderAction


解决方案

Html.Action 调用控制器的动作,这意味着它实例化控制器实体,调用的操作方法,它建立一个模型中返回一个视图的结果。

Html.Partial 使用已经创建的模型(或者可以称为无模式的话)来渲染一个指定的视图。

当使用一个比其他?如果你已经有了一个模型,只是希望有一个可重复使用的视图,选择将 Html.Partial 。如果你看到一些片值得自己的模式和行动,也许是有意义的使用 Html.Action

这个问题是在更大的细节<一个讨论href=\"https://web.archive.org/web/20120703025920/http://www.arrangeactassert.com/when-to-use-html-renderpartial-and-html-renderaction-in-asp-net-mvc-razor-views\">this文章和你在上面看到的是基本上是从它的摘录。

In ASP.NET MVC, what is the difference between:

Html.Partial and Html.RenderPartial
Html.Action and Html.RenderAction

解决方案

Html.Action invokes the controller's action, which means it instantiates the controller entity, calls an action method, which builds a model an returns a view result.

Html.Partial uses already created model (or can be called without model at all) to render a specified view.

When to use one over the other? If you already have a model and just want to have a reusable view, opt to Html.Partial. If you see that some piece deserves its own model and action, maybe it makes sense to use Html.Action.

This question is discussed in much greater details in this article, and what you see above is basically an excerpt from it.

这篇关于Html.Partial VS Html.RenderPartial&安培; Html.Action VS Html.RenderAction。任何一个可以请描述的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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