Hi Jacob,
Html.Partial and Html.RenderPartial:
Both uses to rendering partial view and no need to create action.
Difference:
- Html.Partial renders partial view as an HTML-encoded string while Html.RenderPartial method result directly written to to the HTTP response stream that is it used the same TextWriter object as used in the current webpage/template
- Html.Partial method's result can be stored in a variable, since it returns string type value while Html.RenderPartial method returns void.
- Html.RenderPartial is faster than Html.Partial.
Uses:
- Html.RenderPartial and Html.Partial methods are useful when the displaying data in the partial view is already in the corresponding view model
Html.Action and Html.RenderAction:
Both uses to rendering partial view and need to create action.
Difference:
- Html.Action renders partial view as an HTML-encoded string while Html.RenderAction method result directly written to to the HTTP response stream that is it used the same TextWriter object as used in the current webpage/template
- Html.Action method's result can be stored in a variable, since it returns string type value while Html.RenderAction method returns void.
- Html.RenderAction is faster than Html.Action.
Uses:
- Html.RenderAction and Html.Action methods are useful when the displaying data in the partial view is independent from corresponding view model.
- These methods are also the best choice when you want to cache a partial view.
Posted On:
26-Nov-2015 22:43