c# - MVC. In some reason dynamic css style is empty -
i'm trying apply dynamically generated css style. action returns style content. there simplified examples of code.
controller code:
public class maincontroller:controller{ ... [actionname("dynamicstyles.css")] public contentresult getstyle(){ response.contenttype = "text/css"; return content(".someclass{color: #0f0;}", "text/css"); } }
_layout code
... <head> ... @styles.render("~/content/css") <link href='@url.action("dynamicstyles.css","main")' rel="stylesheet" type="text/css"/> </head>
when request page there empty style. if make direct request httр://localhost/main/dynamicstyles.css
- renders right style file. when watching tab html in firebug, can expand link , shows right style content:
but css tab in firebug dynamicstyles.css
empty.
and no styles applied.
what i'm doing wrong?
additional info: controller has attribute this
[browsercache(preventbrowsercaching = true)] public class maincontroller:controller{...} public class browsercacheattribute : actionfilterattribute { public int duration { get; set; } public bool preventbrowsercaching { get; set; } public browsercacheattribute() { duration = 10; } public override void onactionexecuted( actionexecutedcontext filtercontext) { if (duration < 0) return; httpcachepolicybase cache = filtercontext.httpcontext .response.cache; if (preventbrowsercaching) { cache.setcacheability(httpcacheability.nocache); duration = 0; } else { cache.setcacheability(httpcacheability.public); } timespan cacheduration = timespan.fromseconds(duration); cache.setexpires(datetime.now.add(cacheduration)); cache.setmaxage(cacheduration); cache.appendcacheextension("must-revalidate," + "proxy-revalidate"); } }
well finally, how can possible, this: ,
take out '.css' in actionname , it'll work straight away.
Comments
Post a Comment