title: Dynamically generated Javascript, CSS in ASP.NET MVC
body: <p>ASP.NET allows to generate HTML dynamically using server tags (razor or ASPX). But Is there any good way to generate *.js or *.css content the same way, other than using inline(embedded) CSS/Javascript. Nowadays with technologies like Ajax more and more logic moves from server-side to client side in Javascript. It would be great to have that opportunity to generate JS dynamically using all flexibility that ASP.NET provides for HTML generation.</p>
  
  <p>For example, my Javascript contains <strong>Knockout view model declaration with initial data loaded from server</strong> during Javascript rendering, and some additional js-functions, so in my Html <em>instead of embedded scripts</em> I want to have script references like that:</p>
  
  <pre><code>&lt;script src="~/Scripts/ContactViewModel.js?contactId=@Model.ContactId"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Another example, where developer might need it is using user-profile based CSS. User profile information contains style information (fonts, colors, not just theme) that must be respected during CSS generation, so In my view I will have something like:</p>
  
  <pre><code>&lt;link href="~/Styles/CurrentUserOverrides.css" rel="stylesheet" /&gt;
  </code></pre>
  
  <p><strong>CurrentUserOverrides.css</strong> will be generated dynamically based on profile data of authenticated user.</p>
  
  <p>How to do that using ASP.NET MVC? I want to find solution that will allow me to do this as easy as I create dynamic HTML using ASP.NET, with properly working intellisence and everything else what VS offers for ASP.NET views.</p>