I did some digging on a related question and looking at mvc 3 source, they definitely don't support any attribute other than Duration and VaryByParam The main bug with their current implementation is that if you don't supply either one of these you will get an exception telling you to supply that, instead of an exception say that what you tried to use is not supported. The other major issue was that they will cache even if you turn off caching in the web. Config, which seems really lame and not right The biggest issue I had with it all is that they are using the same attribute which works in both views and partial views, but in reality it should probably be 2 different attributes since the partial view is so limited and behaves a lot differently, at least in it's current implementation.
I did some digging on a related question and looking at mvc 3 source, they definitely don't support any attribute other than Duration and VaryByParam. The main bug with their current implementation is that if you don't supply either one of these you will get an exception telling you to supply that, instead of an exception say that what you tried to use is not supported. The other major issue was that they will cache even if you turn off caching in the web.
Config, which seems really lame and not right. The biggest issue I had with it all is that they are using the same attribute which works in both views and partial views, but in reality it should probably be 2 different attributes since the partial view is so limited and behaves a lot differently, at least in it's current implementation.
Thanks for your answer :) – frennky Jan 26 at 6:09 Here's a nice article that explains this problem: dotnetcurry. Com/ShowArticle. Aspx?
ID=665 – frennky May 7 at 14:45.
Here's a simple way if : Your basic goal is to be able to disable cache during debugging, and enable it during deployment You don't have complicated caching policies (that mean you truly need to respect Web. Config's caching settings) You don't have a complicated deployment system that relies on Web. Config's caching syntax Ideal if you're using XDT web transformations already You just assumed it would already work and are annoyed that it didn't and need a quick fix!
All I did was created a new attribute 'DonutCache'. DonutCache public ActionResult HomePageBody(string viewName) { var model = new FG2HomeModel(); return View(viewName, model); } I store my caching setting in Web. Config (under a new custom name - so as to avoid confusion).
I created a simple helper method to pull the value out. Public static class Config { public static int DonutCachingDuration { get { return int. Parse(ConfigurationManager.
AppSettings"DonutCachingDuration"); } } } Unfortunately you can only initialize an Attribute with a constant, so you need to initialize the attribute in its constructor (you cant just say Attribute(Config. DonutCachingDuration) unfortunately). Note: This doesn't prevent you setting 'varyByParam' in the DonutCache declaration - which is currently the only other property that is usable for caching of Action methods.
Class DonutCacheAttribute : OutputCacheAttribute { public DonutCacheAttribute() { // get cache duration from web. Config Duration = Config. DonutCachingDuration; } } Just use an XDT web transformation's and you're ready to deploy with a longer value.
Tip: You'll probably want to stick a @DateTime.Now.ToString() in your partial view to make sure the cache setting is being respected.
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.
If this isn't appropriate (because you don't want to cache the entire page) - you can use the 'DonutCacheAttribute' from my other answer.
You don't have complicated caching policies (that mean you truly need to respect Web. You don't have a complicated deployment system that relies on Web. You just assumed it would already work and are annoyed that it didn't and need a quick fix!
All I did was created a new attribute 'DonutCache'. I store my caching setting in Web. Config (under a new custom name - so as to avoid confusion).
I created a simple helper method to pull the value out. Unfortunately you can only initialize an Attribute with a constant, so you need to initialize the attribute in its constructor (you cant just say Attribute(Config. Note: This doesn't prevent you setting 'varyByParam' in the DonutCache declaration - which is currently the only other property that is usable for caching of Action methods.
Just use an XDT web transformation's and you're ready to deploy with a longer value. Tip: You'll probably want to stick a @DateTime.Now.ToString() in your partial view to make sure the cache setting is being respected.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.