One way is to change how you render your scripts:
From:
@Scripts.Render("~/bundles/scripts/common")
To:
<script src="@BundleTable.Bundles.ResolveBundleUrl("~/bundles/scripts/common")" type="text/javascript"></script>
Or depending on how you are implementing bundling, you may need:
<script src="@Microsoft.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/scripts/common")" type="text/javascript"></script>
Or for web forms:
<script src="<%= Microsoft.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/scripts/common")%>" type="text/javascript"></script>
Although if there is a way to do it using @Script.Render I'd like to see it.
UPDATE: in response to your comments, as specified in this SO answer, in the pre-release version of System.Web.Optimization
, there is an option called RenderFormat
that will let you do this as well... but I think the stuff above is easier to read for this particular case.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…