An exception is thrown when I call Html.Action
from a view when the controller is decorated with the OutputCache
attribute. But when I remove the attribute from the controller everything works as expected.
I do not want to remove the OutputCache-attribute and I don't understand how the attribute is responsible for throwing the exception. How do I solve this problem?
Controller:
[OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
public class TestController : Controller
{
public PartialViewResult Test()
{
Debug.WriteLine("test");
return PartialView();
}
}
View:
<div>
<!-- Tab 1 -->
@Html.Action("Test")
</div>
Exception:
{"Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'."}
InnerException
{"Child actions are not allowed to perform redirect actions."}
Update I only get the exception when I try to disable the outputcache. Either by adding the above attribute or setting the duration to 0.