Using Less CSS with Visual Studio and IIS Express

UPDATED: So, it turns out this is actually much easier than I had originally documented below. The same thing can actually be accomplished in a much more simple and portable (with this approach, this setting will apply after deployment as well, and not just to your local IIS Express instance) manner with the following entry in your web.config file:

        <mimeMap fileExtension=".less" mimeType="text/css" />

I recently started working on a personal ASP.NET MVC project on which I wanted to use Less CSS for styling. I quickly ran into a problem when I discovered that a IIS Express doesn't have ".less" registered as a valid MIME type, so it won't serve up the file at all. So that forced me to dig around to figure out how to add a mimetype to the IIS Express configuration. I found a working solution, and thought it could potentially help someone else out.

To add the .less extension as a valid MIME type to IIS express follow these steps:

  1. Open a windows command prompt
  2. Switch to the directory that IIS Express is installed in (on my 64 bit Windows 7 system, it was installed in C:\Program Files (x86)\IIS Express)
  3. Execute the following command:
appcmd set config /section:staticContent /+[fileExtension='.less', mimeType='text/css']  

Boom. Works great. Now I'm rollin' with Less CSS in my ASP.NET MVC project developing on IIS Express. Sweetness.


comments powered by Disqus