If I remove the cache attribute on the parent surface controller, it works as expected (but of course then nothing gets cached). Is this a bug with donutcaching or am I implementing it wrong? I would have thought any kind of post simply ignores cache altogether.
I'm not sure if you are implementing it correct or wrong. Why do you want to cache an ActionResult which you post to? If you cache that the model which gets posted is cached and I don't think you want that.
Hi Jeroen - Thats the thing - I dont want to cache it. I want to cache the rest of the page, but I get the above error if I have Donutcaching enabled on the parent surface controller (i.e. the route-hijacked surface controller associated with the doctype). However, it only happens on post to a child action.
In the Hybrid Framework the contact form is embedded directly into the template, so it would never be able to be 'donut-holed' (I dont think?) So, for example, if this was a login form there would be no way to exclude it from the cache while ensuring the rest of the page was cached.
Let's say the user is already logged in, I might like to redirect to the 'member dashboard' action.
It would be the same deal for a login form where there might be lots of other content on the page that would be useful to have cached.
On his blog post he specifically talks about donut caching login forms so I don't think its a bug in the tool itself. Could be something upstream in Umbraco but chances are I'm just not doing it right! WIll test in pure MVC tomorrow and report.
How can I update because it is not showing up on nuget the latest version and it is not allowing me to update it as well through nuget console. Not Found.
Donut caching error when posting to an action
Just wondering if you have come accross the following issue when using a Donut caching with a http POST to a controller action:
I have a cache set on my route-hijacked surface controller for the page, e.g.
and I also have a cache 'hole' defined in my action like so
The above error occurs when I post to my controller action to handle the form, e.g.
If I remove the cache attribute on the parent surface controller, it works as expected (but of course then nothing gets cached). Is this a bug with donutcaching or am I implementing it wrong? I would have thought any kind of post simply ignores cache altogether.
Hello,
I'm not sure if you are implementing it correct or wrong. Why do you want to cache an ActionResult which you post to? If you cache that the model which gets posted is cached and I don't think you want that.
Jeroen
Hi Jeroen - Thats the thing - I dont want to cache it. I want to cache the rest of the page, but I get the above error if I have Donutcaching enabled on the parent surface controller (i.e. the route-hijacked surface controller associated with the doctype). However, it only happens on post to a child action.
Cheers
Barry
Could you perhaps show the entire controller? It's hard to find out what's wrong now.
Jeroen
Sure, its very simple. Parent Surface Controller:
Child action:
It doesnt matter what is in the POST action, even just doing a return CurrentUmbracoPage() throws the error.
As I said removing the DonutOutputCache attribute on the parent controller fixes the issue.
Hmm if you look at the contact controller from the best practises you can see something which is exactly the same: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/Controllers/ContactController.cs
That just works so I don't why you are getting this error now.
Jeroen
The difference is I am rendering my form via an action method on my template:
Sorry, I should have posted the code for that action method before. Again its very simple, creates a model and returns a partial view.
In the Hybrid Framework the contact form is embedded directly into the template, so it would never be able to be 'donut-holed' (I dont think?) So, for example, if this was a login form there would be no way to exclude it from the cache while ensuring the rest of the page was cached.
Yes that is a difference. Why does you register form needs to be 'donut-holed'?
Jeroen
Let's say the user is already logged in, I might like to redirect to the 'member dashboard' action.
It would be the same deal for a login form where there might be lots of other content on the page that would be useful to have cached.
On his blog post he specifically talks about donut caching login forms so I don't think its a bug in the tool itself. Could be something upstream in Umbraco but chances are I'm just not doing it right! WIll test in pure MVC tomorrow and report.
Hello,
Did you test it with a pure MVC and did that work?
Jeroen
Hi Jeroen,
I'm on another project atm but I will get back on this later in the week and feedback any info, cheers.
NB Jeroen I resolved this by updating to the latest beta of the DonutCache tool.
https://www.nuget.org/packages/MvcDonutCaching/1.3.1-beta1
Hi Barry,
How can I update because it is not showing up on nuget the latest version and it is not allowing me to update it as well through nuget console. Not Found.
Any idea?
Kind Regards
Simon - I just checked on Nuget and you'll probably need to use the latest version, which is installed by using
Here is the Nuget page:
https://www.nuget.org/packages/MvcDonutCaching/1.3.1-rc1
Good to hear you've got it fixed!
This worked for me as well. Thanks Bary. HFYR
/Rune
is working on a reply...