On my website I want the user to have the ability to login/logout from any page. When the user select login button a modal dialog will be present to the user for him to enter i
In some cases it may be appropriate to just create a second action method, with caching disabled that is called by your primary action.
/// Use this for normal HTTP requests which need to be cached
[OutputCache(CacheProfile = "Script")]
public ContentResult Foo(string id)
{
return _Foo(id);
}
/// Use this for Html.Action
public ContentResult _Foo(string id)
{
return View();
}
When you need Html.Action
you just call _Foo instead of Foo.
@Html.Action("_Foo", "Bar").ToString();
You can then rely on the parent page to do the caching.
Another way is to just bypass the whole 'CacheProfile' thing for ActionMethod and use my 'DonutCacheAttribute' instead.
The 'CacheProfile' for ActionMethods currently only respects the Duration
and varyByParam
properties - and this method makes it easy to set different caching durations in debug vs. deployment (assuming you're using XDT transformations).