我正在尝试使用
缩小和捆绑我的 css 和 js 文件
我能够找到的所有示例都包含它们在 masterpage / _layout 文件中的所有脚本。
我希望能够拥有一个
@RenderSection("Script", false)
在我的 _layout 文件中并像这样从我的“子视图”中添加脚本
@section Script {
<script src="@Url.Content("~/Scripts/Configuration/Configuration.js")" type="text/javascript"></script>
}
现在我的问题是我如何动态地将文件添加到包中并强制缓存破坏?
现在我有这个
public static void AddBundleFile(this HtmlHelper helper, string path, Type type, int index)
{
var bundle = BundleTable.Bundles.GetRegisteredBundles()
.Where(b => b.TransformType == type)
.First();
bundle.AddFile(path);
}
从我的“子视图”添加文件,但捆绑文件永远不会更新..