I'm trying to use @Umbraco.CahcedPartial to present a image gallery. I would like the cahce to take the querystring of the page into account so that /Mypage?year=2014 return a diffrent cacheresult than /Mypage?year=2013.
The model item passed into the dictionary is of type 'System.Web.HttpValueCollection', but this dictionary requires a model item of type 'Umbraco.Web.Models.RenderModel'.
You can create a marco partial and that will call your partial view. Then you creat a macro that renderds your macro partial view. You can define a year parameter on the macro and pass the year querystring to that. Macro's will be cached on parameter values.
This will actually work the way you want, you have to pass an additional parameter generating a unique due passed of the parameters that affect the layout. IE either of these.
CachedPartial with querystring
I'm trying to use @Umbraco.CahcedPartial to present a image gallery. I would like the cahce to take the querystring of the page into account so that /Mypage?year=2014 return a diffrent cacheresult than /Mypage?year=2013.
Been trying this in my template
But that results in a YSOD saying
The model item passed into the dictionary is of type 'System.Web.HttpValueCollection', but this dictionary requires a model item of type 'Umbraco.Web.Models.RenderModel'.
Any ideas?
What you are trying will not work. If you look at the documentation of the cached partial :
http://our.umbraco.org/documentation/Reference/Mvc/partial-views at the bottom.
You can create a marco partial and that will call your partial view. Then you creat a macro that renderds your macro partial view. You can define a year parameter on the macro and pass the year querystring to that. Macro's will be cached on parameter values.
You can find documentation on macro partials here : http://our.umbraco.org/documentation/reference/templating/macros/Partial-View-Macros/
Dave
This will actually work the way you want, you have to pass an additional parameter generating a unique due passed of the parameters that affect the layout. IE either of these.
Or this will take a list of viewData Key's and attach them all.
Another cleaner option is to add a extension method in your site code somewhere.
Then call it like so:
is working on a reply...