Is there a possibility how to change the way how System.Web.Optimization renders bundles?
From:
<script src="/bundles/js/bundlename?v=GMFuN8gzKMcwk5BwaMfgjUlieAXKThyQd8twrVplJ8A1"></script>
To something custom like this:
<script src="/bundles/js/v-GMFuN8gzKMcwk5BwaMfgjUlieAXKThyQd8twrVplJ8A1/bundlename"></script>
UPDATE: Not ideal but small nasty workaround:
public static class BundlesHelper
{
public static IHtmlString RenderScripts(params string[] paths)
{
#if DEBUG
return System.Web.Optimization.Scripts.Render(paths);
#endif
// Get raw string
var rawString = System.Web.Optimization.Scripts.Render(paths).ToHtmlString();
// Get version value
var version = Regex.Match(rawString, @"\?v=([0-9a-zA-Z_-])+").Value;
// Remove old hash
rawString = rawString.Replace(version, "");
// Remove script end tag
rawString = rawString.Replace("</script>", "");
// Get last index of "/"
var index = rawString.LastIndexOf('/');
// Return new string
return new HtmlString(rawString.Insert(index, "/v-" + version.Replace("?v=", "")) + "</script>");
}
}
No. That's not the point. The query string portion is a cache buster. The file is located where the script src says it is, and that doesn't change. In your desired version the actual physical location of the file would have to change.