c# - Asp.Net Mvc Method OutputCache attribute set based on HttpContext.Current.IsDebuggingEnabled -


i trying set method attribute based on debug flag. expected have compile time issues this. perhaps can think of workaround works similar if worked.

[outputcache(     nostore = httpcontext.current.isdebuggingenabled,      duration=(httpcontext.current.isdebuggingenabled)?0:15 )]///todo: remove attribute after testing! public actionresult rendersomething(int somethingid) { ... } 

can not use preprocessed conditionals?

#if debug     [outputcache(         nostore = httpcontext.current.isdebuggingenabled,          duration = 0)] #else     [outputcache(         nostore = httpcontext.current.isdebuggingenabled,          duration = 15)]     #endif 

..?

edit: have confirmed work test of using serializable attribute. should work you're trying achieve (not sure if it's best solution though.. works!).


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -