Firstly, to answer only the question, you can simply use a simple link in your html file
<script src='bundles/mybundle' type='text/javascript' language='text/javascript'></script>
=> which will include your javascript package on the page
The problem with this approach is that if you modify the * .js file contained in the bundle, the modification will not be visible in the bundle. It's all about "unpacking the package cache", a nice feature of ASP.NET, but accessible only from the razor template ... Obviously, you also restart the pool (but it is rather slow and difficult to automate) :)
To work around this problem, you can define your own ASP.NET MVC controller with the following
using System.Linq; using System.Web.Mvc; using System.Web.Optimization; namespace Controllers { public class DebugBundlesController : Controller {
and you use it like:
<script src='debugbundles/mybundle' type='text/javascript' language='text/javascript'></script>
=> now, every time you make changes, the package will be regenerated.
Remember to use this only during development, because you remove almost all the benefits of packages (for example, caching clients and servers)
Christophe Blin Dec 29 '15 at 9:20 2015-12-29 09:20
source share