when building cached partials that work with many different instances of the same partial view (e.g. using the same partial more than once on a page with different ViewDataDictionary or different model), it is necessary to either name each instance differently (ugh), or not cache.
By adding an optional argument to the CachedPartial Html helper method, we can vary the cache-key depending on the context of insertion. For maximum flexibility, pass the model and the viewData to the function so it can use that data to format a cacheKey suffix.
A typical use would be something like:
@Html.CachedPartial(
"EventListings"
, FeedRepository.getFeed(new CalendarEventsModel
{
StartingDate = DateTime.UtcNow.Date
, Count = 10
})
, 0
, contextualKeyBuilder: (model, viewData) =>
{
return (model as CalendarEventsModel).StartingDate.ToString();
}
)
Umbraco CMS
Watch a five minute introduction video
Umbraco - the simple, flexible and friendly ASP.NET CMS
More than 177,000 sites trust Umbraco
For the first time on the Microsoft platform a free user and developer friendly CMS that makes it quick and easy to create websites - or a breeze to build complex web applications. Umbraco has award-winning integration capabilities and supports ASP.NET MVC or Web Forms, including User and Custom Controls, out of the box. It's a developers dream and your users will love it too.
Used by more than 177,000 active websites including http://daviscup.com, http://heinz.com, http://peugeot.com, http://www.hersheys.com/ and The Official ASP.NET and IIS.NET website from Microsoft (http://asp.net / http://iis.net) you can be sure that the technology is proven, stable and scales.
To view more examples please visit http://umbraco.com/why-umbraco/#caseStudies
Downloading
The downloadable Umbraco releases live at http://our.umbraco.org/download.
Forums
We have a forum running on http://our.umbraco.org. The discussions group on Google Groups is for discussions on developing the core, and not on Umbraco-implementations or extensions in general. For those topics, please use http://our.umbraco.org.
Contribute to Umbraco
If you want to contribute back to Umbraco you should check out our guide to contributing.
Found a bug?
Another way you can contribute to Umbraco is by providing issue reports, for information on how to submit an issue report refer to our online guide for reporting issues.
To view existing issues please visit http://issues.umbraco.org
