The version with the @Html.Partial doesn't get cached.
The version with macro can be cached depending on your macro cache settings. The advantage is that when using macro parameters the macro can be reused. Also the macro get's cached depending on the parameter values. So when you use the same macro twice on your page with different cache settings than these will be cached seperatly.
Umbraco also supports rendering of cached partial views using :
@Html.CachedPartial("MyPartialName", new MyModel(), 3600)
So other than caching, which can be worked around by using @HtmlCachedPartial, there's no difference other than how they look?
I think how they look and read is a factor here also (to my eyes anyway). The macro version looks easier to read, more expressive. Passing in the ViewDataDictionary looks kinds of hacky in comparison, especially if it only has one parameter.
MVC macroPartial parameter vs ViewDataDictionary
I'm curious about the differences between the use of parameters and viewdatadictionary.
When should I render a partial with a viewdatadictionary and when should i render a macro partial with parameters. For example.
or
Are there differences in use, speed, caching etc?. As far as I can tell the only use of a macro partial is to use it within a RichTextEditor
I came to the forum with this exact same question. Made a sad face when I saw no replies.
Hi Rick, Charles,
The version with the @Html.Partial doesn't get cached.
The version with macro can be cached depending on your macro cache settings. The advantage is that when using macro parameters the macro can be reused. Also the macro get's cached depending on the parameter values. So when you use the same macro twice on your page with different cache settings than these will be cached seperatly.
Umbraco also supports rendering of cached partial views using :
Full documentation can be read here in the caching part : https://our.umbraco.org/documentation/Reference/Templating/Mvc/partial-views
Dave
Thanks Dave.
So other than caching, which can be worked around by using
@HtmlCachedPartial
, there's no difference other than how they look?I think how they look and read is a factor here also (to my eyes anyway). The macro version looks easier to read, more expressive. Passing in the
ViewDataDictionary
looks kinds of hacky in comparison, especially if it only has one parameter.There's a good explanation of the ViewDataDictionary syntax on StackOverflow if it's confusing to anyone.
is working on a reply...