How can we enable caching for Bundles in MVC5

后端 未结 2 504
温柔的废话
温柔的废话 2021-01-23 13:20

I have created 2 bundles in my mvc project as given below:

 public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBund         


        
2条回答
  •  走了就别回头了
    2021-01-23 14:01

    Add a key in webconfig

      
      
    
    

    Create a class, where we define the format for both JavaScript and styles. using System.Configuration;

    namespace BundlingSample   
    {  
    public class SiteKeys {  
        public static string StyleVersion {  
            get {  
                return "";  
            }  
        }  
        public static string ScriptVersion {  
            get {  
                return "";  
            }  
        }  
    }  
    }
    

    @Styles.RenderFormat(SiteKeys.StyleVersion,"~/Content/css") 
    @Scripts.RenderFormat(SiteKeys.ScriptVersion,"~/bundles/jquery")
    

提交回复
热议问题