我在我的应用程序中使用bundle并且它工作正常但是当我更改任何js文件时出现问题,它的更改并不反映我需要清除缓存。下面是我的Bundle Class。
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.IgnoreList.Clear();
bundles.Add(new ScriptBundle("~/bundles/js")
.Include("~/Scripts/js/jquery-2.1.1.js")
.Include("~/Scripts/js/bootstrap.js")
.Include("~/Scripts/js/jquery-ui.js")
.Include("~/Scripts/js/jquery.dataTables.js")
.Include("~/Scripts/js/amplify.core.js")
.Include("~/Scripts/js/amplify.store.js")
.Include("~/Scripts/js/bootstrap-datepicker.js")
.Include("~/Scripts/js/bootstrapValidator.js")
.Include("~/Scripts/js/jasny-bootstrap.js")
.Include("~/Scripts/ApplicationCommand/AppCommands.js")
.Include("~/Scripts/ApplicationCommand/ControlName.js")
.Include("~/Scripts/ApplicationCommand/MDVisionServices.js")
.Include("~/Scripts/ApplicationCommand/store.js")
.Include("~/Scripts/ApplicationCommand/utility.js")
.Include("~/Controls/Admin/Admin_SubMain.js")
.Include("~/Controls/Admin/RefProvider.js")
.Include("~/Controls/DashBoard/DashBoard.js")
.Include("~/Controls/patient/Patient_Search.js")
.Include("~/Controls/Scheduling/Scheduling_Calendar.js")
.Include("~/Controls/Scheduling/Scheduling_Provider_Schedule.js")
.Include("~/Controls/Scheduling/Scheduling_Search.js")
.Include("~/Controls/Scheduling/Scheduling_WaitList.js")
.Include("~/Controls/Search/Search_Admin.js")
.Include("~/Scripts/MDVisionDefault.js")
.Include("~/Scripts/js/jquery.toastmessage.js")
.Include("~/Scripts/js/jquery.autocomplete.js")
.IncludeDirectory("~/Scripts/ApplicationCommand", "*.js", searchSubdirectories: true)
.IncludeDirectory("~/Controls", "*.js", searchSubdirectories: true)
//.IncludeDirectory("~/assets/vendor", "*.js", searchSubdirectories: true)
);
bundles.Add(new StyleBundle("~/bundles/css")
.Include("~/Content/Blue/bootstrap.css")
.Include("~/Content/Blue/bootstrapValidator.css")
);
}
下面是我的aspx页面,我注册了我的包。
<asp:PlaceHolder ID="PlaceHolder2" runat="server">
<%: Scripts.Render("~/bundles/js") %>
<%: Styles.Render("~/bundles/css") %>
</asp:PlaceHolder>
现在的问题是,当我更改任何js文件时,我也需要清除缓存。任何人都可以给出解决方案。
修改
我听说过Cache Busting但是如果这对我的情况有帮助,请解释一下,请解释我如何在我的情况下使用。 感谢
答案 0 :(得分:0)
花费一些时间后,我将问题排除在外并解决了问题。
在HTML页面上,您需要根据以下技术在头标记下的aspx页面上进行渲染。
<script src=<%: System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/AppCommands") %>></script>
<script src=<%: System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/AppSecurity") %>></script>
<script src=<%: System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/ControlName") %>></script>
<script src=<%: System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/MDVisionServices") %>></script>
<script src=<%: System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/store") %>></script>
<script src=<%: System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/utility") %>></script>
<script src=<%: System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/Adminjs") %>></script>
Bundles.ResolveBundleUrl()会将js或css放置一年,如果上传了一些更改,它将自动更新引用。