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: enter image description here

but css tab in firebug dynamicstyles.css empty. enter image description here

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: loaded dynamicstyle.css content , empty dynamicstyle.css w/o content

take out '.css' in actionname , it'll work straight away.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -