The question of using variables in CSS seems to come up from time to time so I decided to do a bit of experimenting and ASP.NET MVC just makes it too easy to implement.
Basically you just point a <link> to your controller, add a MapRoute to get it there, define a class, add some definitions, add a strongly typed view and change the contentType of the view.
That’s it. The thing I’m wondering is if this is in any way useful. I imagine using it for a CMS and including a backend to control the site colors and such may be interesting but I’m not fully convinced.
Good question–that can really depend on app. I always try and keep a few major performance improvement ideas in the back pocket in case you need one real quick. You should just be able to use the normal ASP.NET MVC caching options though.
Yes, I used [OutputCache] in the example. It does consume a bit of memory, right? A few kb of cache isn’t going to make or break anything though. I don’t know if that means it’s just not worth doing or that I may as well because it won’t hurt anything.
Here’s the big question though. Since the browser is going to cache the file anyway, it will take it from browser cache instead of from the server after the first visit, right? OutputCaching will only apply for multiple simultaneous hits, right?
You’re too kind. I honestly don’t know that this project has any real world value.
Version 1.0 is the one that comes up if you go to http://asp.net/mvc and download the installer. I believe version 2.0 is still a release candidate. There’s nothing in this project that uses any Version 2.0 only items.