c# - ASP.NET MVC 4 Bundling - Individual File URLs in DEBUG mode -
problem:
in html5 offline app beingness done in asp.net mvc 4.5, bundling , minifying styles , scripts using framework's built-in feature. working pages themselves, writing cache manifest, (because of we writing it) emitting bundled url.
and so, not able debug javascript in offline mode, individual debug js files not getting application cache.
code: registerbundlesthis how our bundleconfig.registerbundles
look:
// more info on bundling, visit http://go.microsoft.com/fwlink/?linkid=254725 public static void registerbundles(bundlecollection bundles) { bundles.add(new scriptbundle("~/bundles/scripts").include( "~/scripts/*.js" )); }
html markup and include in our _layout.cshtml
pages this:
@system.web.optimization.scripts.render("~/bundles/scripts")
this works pages, emitting individual js files when debug
true
, , 1 bundled file when debug
false
.
output in debug=true
<script src="/scripts/scriptone.js"></script> <script src="/scripts/scripttwo.js"></script> <script src="/scripts/scriptthree.js"></script>
output in debug=false
<script src="/bundles/scripts?v=b0_rvam_5ifnrecgnnq3fo8qqp4vylodtcuj-2mxsua1"></script>
cache-manifest and how include scripts our cachemanifest
@system.web.optimization.bundletable.bundles.resolvebundleurl("~/bundles/scripts")
output in debug=true
, debug=false
/bundles/scripts?v=b0_rvam_5ifnrecgnnq3fo8qqp4vylodtcuj-2mxsua1
what want? we know if there way cache-manifest output this:
output in debug=true
/scripts/scriptone.js /scripts/scripttwo.js /scripts/scriptthree.js
output in debug=false
/bundles/scripts?v=b0_rvam_5ifnrecgnnq3fo8qqp4vylodtcuj-2mxsua1
the msdn documentation talks scripts.renderformat
method, looked candidate doing want. intellisense complaining renderformat
method not nowadays in version of system.web.optimization
referenced.
but, (once again) google, this reply here on so explaining renderformat
method in fact, included in next version's alpha release. , comment on answer linked page explains how install it:
pm> install-package microsoft.aspnet.web.optimization -pre
with version, cache-manifest
changed to:
@system.web.optimization.scripts.renderformat("{0}","~/bundles/scripts")
and have cache manifest emit individual files while debug=true
.
apparently, msdn documentation not in sync current stable release !
c# .net asp.net-mvc razor asp.net-mvc-4
No comments:
Post a Comment