Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction

后端 未结 13 987
感动是毒
感动是毒 2020-11-22 04:03

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

  • Html.Partial and Html.RenderPartial
  • Html.Action and Html.
13条回答
  •  爱一瞬间的悲伤
    2020-11-22 04:26

    Here is what I have found:

    Use RenderAction when you do not have a model to send to the view and have a lot of html to bring back that doesn't need to be stored in a variable.

    Use Action when you do not have a model to send to the view and have a little bit of text to bring back that needs to be stored in a variable.

    Use RenderPartial when you have a model to send to the view and there will be a lot of html that doesn't need to be stored in a variable.

    Use Partial when you have a model to send to the view and there will be a little bit of text that needs to be stored in a variable.

    RenderAction and RenderPartial are faster.

提交回复
热议问题