Here are what I consider my guidelines on using Html.Action or Html.Partial
Html.Partial
- Use
Html.Partial
when you are rendering static content or,
- If you are going to pass data from the ViewModel that is being sent to the main view
Html.Action
- Use
Html.Action
when you actually need to retrieve additional data from the server to populate the partial view
Basically, if is static, use Html.Partial()
. If dynamic, model independent data, use Html.Action()
. There are probably more scenarios, but this will give you a good idea of where/how to go. Html.RenderPartial()
and Html.RenderAction()
are interchangeable for the similarly named functions above.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…