Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Enrico Magboo 7 posts 127 karma points
    Jan 12, 2017 @ 12:36
    Enrico Magboo
    0

    The "OutputCacheAttribute for child actions only supports Duration, VaryByCustom, and VaryByParam values..." error occurs

    So I just watched the video tutorial of Umbraco particularly the surface controller part. And I learned that for server side controls like textbox (forms), we have to create partial view as *.cshtml and the created surface controller with HttpGet annotation will return that partial view.

    However, when I try to add another annotation:

    [OutputCache(NoStore - true, Duration = 0, VaryByParam = "None")]

    error occurs saying that 'The "OutputCacheAttribute for child actions only supports Duration, VaryByCustom, and VaryByParam values...'

    Reason for adding that annotation is to handle browser back button (reference link). Problem in my Umbraco powered mvc website is that when I click Log Out link, surface controller will clear the session and redirect to homepage. And from the homepage which has the login form (userame textbox, password & submit button as partial view), when the browser back button is pressed, browser displays the secured page/the previously entered page while he/she is logged in.

  • David Peck 687 posts 1863 karma points c-trib
    Jan 12, 2017 @ 17:03
    David Peck
    0

    Not sure I fully understand, but checkout Donut caching. That probably provides more options for you. http://www.devtrends.co.uk/blog/donut-output-caching-in-asp.net-mvc-3

  • Enrico Magboo 7 posts 127 karma points
    Jan 13, 2017 @ 08:02
    Enrico Magboo
    100

    Hi David, I checked the link you provided and read that full page caching (which is what I need in my scenario) is already supported since MVC 1 (see quote below).

    What I did to resolve my problem is to disable the cache all throughout the pages by adding custom Global.asax.cs (by default, it is inherited to Umbraco.Web.UmbracoApplication). Inside my Global.asax.cs: -- Oops, tried to add here my code but the preview shows a 1-liner code, making my code difficult to read.

    Impact of this is that when the browser back button is being pressed, it triggers server side/my controllers and I can then handle thoroughly the flow especially the login session of the user.


    WHAT IS DONUT CACHING?
    

    When we talk about output caching, there are three different scenarios that we may encounter:

    FULL PAGE CACHING

    Full page caching is where you cache the entire page with no substitutions. It is handled with the built-in OutputCache attribute that has been available since ASP.NET MVC 1.

Please Sign in or register to post replies

Write your reply to:

Draft