moonpyk / mvcdonutcaching

ASP.NET MVC Extensible Donut Caching brings donut caching to ASP.NET MVC 3 and later. The code allows you to cache all of your page apart from one or more Html.Actions which can be executed every request. Perfect for user specific content.
https://github.com/moonpyk/mvcdonutcaching
MIT License
142 stars 50 forks source link

Child actions are not allowed to perform redirect actions. #45

Open Sebosek opened 9 years ago

Sebosek commented 9 years ago

Sometimes, I don't know why, I got error "Child actions are not allowed to perform redirect actions." error message. This error comes from ˙@Html.Action("CookieLaw", "Home", true)˙ and CookieLaw action contains just one line:

public ActionResult CookieLaw()
{
    return PartialView();
}

and View for this action:

@if (ViewBag.IsCookieLawConfirmed == null || !(bool)ViewBag.IsCookieLawConfirmed)
{
    <script type="text/javascript">
        var CasinoLaw = function () {
            // public
            this.HideCookieLaw = function () {
                document.getElementById("casino-cookie-law").className += " hide";
                SetCookie("@Apollo.Casino.Frontend.Features.Attributes.CookieLawAttribute.COOKIE_LAW", 1, 3650);
            };
            // private
            var SetCookie = function (cookieName, cookieValue, nDays) {
                var today = new Date();
                var expire = new Date();
                if (nDays == null || nDays == 0) nDays = 1;
                expire.setTime(today.getTime() + 3600000 * 24 * nDays);
                document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString() + ";path=/";
            };
        };
    </script>

    <div id="casino-cookie-law" class="cookie-law">
        <div class="wrapper">
            <button type="button" onclick="javascript: var c = new CasinoLaw(); c.HideCookieLaw();">OK</button>
            <p>@PortalInfo.GetText("Casino.CookieLawPolicy.Text")</p>
        </div>
    </div>
}

So, I'm not using redirect. Please tell me what information can I provide to help to investigate this issue...

migig commented 9 years ago

I had similar error. You must be performing a redirect in a child action somewhere. Just make sure if this is the case. Because you can't do that (the framework doesn't allow it).