.less 文件在 IIS6 上静态提供.NET 4 MVC3
在 .NET 4 MVC3 项目中,我在 IIS6 上运行本地计算机(不要问为什么)。它在 IIS 中具有到 v4 aspnet_isapi.dll 的正确通配符映射,.less 扩展名也是如此。
Web.config 定义了这些 IIS6 和 IIS7 httphandlers。
<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>
浏览 /path/to/nonexisting.less
会抛出一个正确的错误,该错误向我显示 LessCssHttpHandler 正在运行的堆栈跟踪。
浏览到 /path/to/existingfileondisk.less
只是按原样下载原始的 less 文件。对我来说,似乎现有的静态文件处理程序在这里正在运行,尽管我不确定。
我缺少什么(除了新机器;))?
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 ;))?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也遇到了这个问题,下一个解决方案解决了这个问题:
如果您使用的是 IIS 6 或更早版本,或者没有使用 IIS 的集成管道,则需要配置 Web 服务器的设置,以便将 .LESS 文件的请求路由到ASP.NET 引擎(以便它们可以由 .LESS HTTP 处理程序处理)。有关更多详细信息,请阅读 如何 ASP. NET 网页在 Web 服务器上处理
如何配置 IIS6 的步骤:
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:
我建议您将 .less 文件全部放在一个文件夹中。假设您在 root 上创建了一个名为 Less 的文件夹。您必须将此行添加到 global.asax 才能使其正常工作:
I suggest you to put your .less files all inside a folder. Let's say you created a folder named Less on root. You have do add this line to global.asax to make it work: