我可以在.net 4 Asp.Net Web应用程序中使用Bundling [Bundle.Config]

Sun*_*nil 4 javascript bundle asp.net-4.0 bundling-and-minification

我在.Net framework 4中有我的应用程序.它是一个Asp.Net Web Application.i需要使用Bundle.Config才能使用Bundling功能.

我已经阅读了许多文档,说它是.Net framework 4.5中的功能,以及Asp.Net MVC Application中的功能.

我需要在aspx页面中为Scripts创建一个包.我可以在我的文件中包含Bundle.Config,以便Bundling工作.

th1*_*ey3 12

是的,您可以在ASP.net中使用捆绑4. Nuget Package Manager用于安装Microsoft ASP.Net Web Optimization Framework到您的项目.然后global.asaxApplication_Start方法中注册bundle .像这样的东西 -

    var jqueryBundle = new ScriptBundle("~/Scripts/jquery");
    jqueryBundle.Include(new string[] { 
        "~/Scripts/jquery-1.8.3.js",
        "~/Scripts/jquery-ui-1.9.1.custom.min.js",
        "~/Scripts/jquery-ui-timepicker-addon.js",
        "~/Scripts/jquery.validate.js",
        "~/Scripts/jquery.validate-additional-methods.js"
    });

    BundleTable.Bundles.Add(jqueryBundle);
Run Code Online (Sandbox Code Playgroud)

然后在你的aspx页面或masterpage致电捆绑 -

    <%= System.Web.Optimization.Scripts.Render("~/Scripts/jquery") %>
Run Code Online (Sandbox Code Playgroud)