Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.less files are statically served on IIS6 + .NET 4 MVC3

In a .NET 4 MVC3 project I'm running a local machine on IIS6 (don't ask why). It has a proper wildcard mapping in IIS to the v4 aspnet_isapi.dll, and the same goes for the .less extension.

Web.config has these IIS6 and IIS7 httphandlers defined.

<system.web>
  <httpHandlers>
    <add type="dotless.Core.LessCssHttpHandler,dotless.Core" validate="false" path="*.less" verb="*" />
  </httpHandlers>
</system.web>

<system.webServer>
  <handlers>
    <add name="less" type="dotless.Core.LessCssHttpHandler,dotless.Core" path="*.less" verb="*" />
  </handlers>
</system.webServer>

Surfing to /path/to/nonexisting.less throws a proper error which shows me a stacktrace that the LessCssHttpHandler is in action.

Surfing to /path/to/existingfileondisk.less just downloads the original less file as is. To me it seems that an existing static file handler is in action here, though I'm not sure.

What am I missing (apart from new machine ;))?

like image 609
Martin Kool Avatar asked Oct 24 '22 01:10

Martin Kool


1 Answers

I also encountered this problem, and next solution fixed the problem:

If you are using IIS 6 or earlier or are not using IIS's integrated pipeline, you'll need to configure your web server's settings so that requests for .LESS files are routed to the ASP.NET engine (so that they can be processed by the .LESS HTTP Handler). For more details read How ASP.NET Web Pages are Processed on the Web Server

Steps how to configure IIS6:

  1. Right Click on the Web Site -> Properties -> Home Directory -> Configuration -> Application extensions -> Add -> :
    • Executable = path to the asp.net DLL (f.e. c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll )
    • Extention = .less
    • Uncheck “Verify that file exist”
  2. Configure Mime Type: Right Click on the Web Site -> Properties -> HTTP Headers -> MIME types -> New -> Extension = .less , MIME type =”text/css”
like image 185
Inna Avatar answered Nov 02 '22 08:11

Inna