I'm having the problem described by @Aviv in this post: http://www.devtrends.co.uk/blog/donut-output-caching-in-asp.net-mvc-3#125
I looked for the error here and on Codeplex but not found.
The environment is Medium Trust!
Route
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.IgnoreRoute("elmah.axd");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new[] { "LetsGo.Controllers" }
);
}
Controller
[DonutOutputCache(CacheProfile = "StaticPage")]
public ActionResult Index()
{
return View(_themeParty.Repository.Query().Published(true).ToList());
}
[ChildActionOnly]
[DonutOutputCache(CacheProfile = "DataCache")]
public PartialViewResult Subsidiaries() { return PartialView(_subsidiaries.Repository.Query().Published().ToList()); }
Web.config
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="DataCache" enabled="true" duration="10800" varyByParam="*" />
<add name="StaticPage" enabled="true" duration="21600" varyByParam="*" />
<add name="ByHeader" enabled="true" duration="300" varyByHeader="*" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
_Layout.cshtml
...
@Html.Action("Subsidiaries", "Home", new { area = "" })
...
Full error
Server Error in '/LetsGo' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
DevTrends.MvcDonutCaching.KeyGenerator.GenerateKey(ControllerContext context, CacheSettings cacheSettings) +777
DevTrends.MvcDonutCaching.DonutOutputCacheAttribute.ExecuteCallback(ControllerContext context, Boolean hasErrors) +43
System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception) +168
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +652
System.Web.Mvc.Controller.ExecuteCore() +161
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +304
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +61
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +461
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +370
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272