Pregunta

I am using the most excellent Cassette for bundling assets in ASP.NET. However, there are times when it would be handy to turn off the URL rewriting altogether. I know there are solutions for preventing minification or stopping bundling, but I want the Cassette HtmlHelper to simply (temporarily) emit the original asset URLs.

For example, rather than emitting:

<script src="/cassette.axd/asset/Scripts/jquery-1.7.2.js?DXiW4rsj-I4m5SsioHU1CzVN9Ec=" type="text/javascript"></script>

Cassette would emit the original:

<script src="/scripts/jquery-1.7.2.js" type="text/javascript"></script>

Some background: I am playing around with InProcess bootstrapping of an ASP.NET MVC application for Integration Tests. The '.axd' and Url-rewriting aspects of Cassette are just one more thing to worry about, so it would be handy to effectively turn Cassette off in some tests.

¿Fue útil?

Solución 2

I posted the same question on the Cassette Google Group, and the lead dev (Andrew Davey) reckons the simplest way to achieve this is to wrap the Cassette HTML Helper methods with a helper of your own which strips out the '/cassette.axd/asset/' part of the URL. The query-string hash parameter at the end of the URL is then simply ignored.

As Andrew says, it's a bit of a hack but I'm quite happy to do this when running integration tests.

(The linked Google Group thread also suggests a more elegant path of exploration to achieve this.)

Otros consejos

IsHtmlRewritingEnabled in your Cassette configuration settings defaults to true. set it to false. See here for more details

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top