7

I have an ASP.Net MVC application which compiles .less files into CSS. In a particular scenario if I hit my endpoint

http:///Account/ResetPassword?t=eyJ0eXAiOiJKV1Qi...

the query string results in a .less compilation warning

directive block with unrecognised format on line 1 in file '~/Content/packageForm.less': []: /beginning of file [1]: @t: eyJ0eXAiOiJKV1Qi...;
^ [2]: @import "setup.less"; directive block with unrecognised format on line 1 in file '~/Content/packageForm.less': []: /beginning of file [1]: @t: eyJ0eXAiOiJKV1Qi...;
^ [2]: @import "setup.less"; directive block with unrecognised format on line 1 in file '~/Content/IE.less': []: /beginning of file [1]: @t: eyJ0eXAiOiJKV1Qi...;
^ [2]: #notes{ directive block with unrecognised format on line 1 in file '~/Content/IE.less': []: /beginning of file [1]: @t: eyJ0eXAiOiJKV1Qi...;
^ [2]: #notes{

If I remove the query string parameter 't' then no compilation errors occur.

Does anyone have a solution?

Thanks,

Paul.

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Paul Houlston
  • 246
  • 2
  • 7
  • Is the endpoint you're hitting the one from which the compiled less i.e. CSS, is served? – Russ Cam Dec 10 '14 at 10:43
  • The endpoint serves up HTML, i.e. is an MVC action delivering HTML. If it is the first hit into the application after compilation or redeploy (so the application is JIT compiling) then the above occurs. This is when the .less is compiled. Subsequent calls to this endpoint after the JITing then no issues occur because the .less has been compiled. – Paul Houlston Dec 11 '14 at 11:54
  • @PaulHoulston I'm having this issue too. Have you figured out how to solve it? – amp Jun 01 '15 at 23:01
  • also see: http://stackoverflow.com/questions/16945938/bundletransformer-less-inject-variables-depending-on-context-request – Bass Jobsen Jun 02 '15 at 21:53

2 Answers2

5

The issue occurs due to a possible bug in dotless WebOptimization Adapter.

To workaround the issue, please add disableParameters="true" to dotless configuration section in your Web.config as shown below:

<dotless minifyCss="false" cache="true" web="true" disableParameters="true" />
ogggre
  • 2,204
  • 1
  • 23
  • 19
  • Indeed, if I apply this solution it seems to solve the problem. But I would like to know if there is another solution because maybe in the future I would like to use dotless parameters. Have you some alternative solution? – amp Jun 01 '15 at 23:04
4

I just solved the problem by updating dotless and dotless adapterfor System.Web.Optimization to their last available versions:

  • dotless: new version 1.5.0
  • dotless adapterfor System.Web.Optimization: new version 1.3.3

For history on this problem, and the resolution, see the GitHub issue "Empty CSS generation at startup" and the related pull request that fixed it.

Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
amp
  • 11,754
  • 18
  • 77
  • 133