Developer Logs

Every once in awhile I hit a (technical) wall, stumble upon a great tool or look for a reason to increase my English.
This is my place to share, welcome to my logs.

Add Less to IIS Express for all Visual Studio projects

I like .less alot, we use it in most of our webprojects. With the release of Visual Studio 2013 Update 1 a new feature has arrived. Full Less integration within VS, thats awesome.

To use Less in your project you can simply add the following lines to your Web.Config file:

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

Add Less to every project by default

When you are like me, and use Less in almost all of your projects and use IIS Express to run your webprojects and don't want to add the lines to your Web.Config all the time. You can add it to your default IIS Express configuration, like so:

  1. Navigate to C:\Users\username\Documents\IISExpress\config
  2. Open applicationhost.config with Visual Studio or your favorite text-editor.
  3. Search for the word mimeMap, you should find lots of 'em.
  4. Add the following line to the top of the list: <mimeMap fileExtension=".less" mimeType="text/css" />.

The result should be something like this:

<staticContent lockAttributes="isDocFooterFileName">
    <mimeMap fileExtension=".less" mimeType="text/css" />
    <mimeMap fileExtension=".323" mimeType="text/h323" />
    <mimeMap fileExtension=".3g2" mimeType="video/3gpp2" />
    <mimeMap fileExtension=".3gp2" mimeType="video/3gpp2" />
    <mimeMap fileExtension=".3gp" mimeType="video/3gpp" />
    <mimeMap fileExtension=".3gpp" mimeType="video/3gpp" />
    <mimeMap fileExtension=".aac" mimeType="audio/aac" />
    ...

Restart Visual Studio, delete the mimeMap from your Web.Config and you're setup!

Picture of Johan Dorper
I'm Johan a .NET Developer (prefer C#) / ScrumMaster from Nunspeet, The Netherlands.
Feel free to mention me on Twitter or drop an e-mail.
comments powered by Disqus