国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

基于Asp.Net MVC4 Bundle捆綁壓縮技術的介紹

2024-07-10 12:45:53
字體:
來源:轉載
供稿:網友

很高興,最近項目用到了Asp.Net MVC4 + Entity Framework5,發現mvc4加入了Bundle、Web API等技術,著實讓我興奮,以前是用第三方的,這里主要說說Bundle技術。

很多大網站都沒有用Bundle技術造成很多資源浪費與性能的犧牲,別小瞧 用上了你會發現他的好處:

將多個請求捆綁為一個請求,減少服務器請求數

 沒有使用Bundle技術,debug下看到的是實際的請求數與路徑

 

使用Bundle技術,并且擁有緩存功能
調試設置為Release模式并按F5或修改web.config,就可以看到合并與壓縮的效果

壓縮javascript,css等資源文件,減小網絡帶寬,提升性能

后臺配置

  MVC4在架構上有些變動,簡化了原來的Global.asax,增加了一些靜態的配置文件在App_Start下面,留意下BundleConfig.cs,顧名思義是Bundle的配置,所有它的配置在這里進行就可以了,當然也可以單獨的配置文件。

代碼如下: public class BundleConfig { // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include( "~/Scripts/jquery-ui-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*")); // Use the development version of Modernizr to develop with and learn from. Then, when you're // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( "~/Scripts/modernizr-*")); bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css")); bundles.Add(new StyleBundle("~/Content/themes/base/css").Include( "~/Content/themes/base/jquery.ui.core.css", "~/Content/themes/base/jquery.ui.resizable.css", "~/Content/themes/base/jquery.ui.selectable.css", "~/Content/themes/base/jquery.ui.accordion.css", "~/Content/themes/base/jquery.ui.autocomplete.css", "~/Content/themes/base/jquery.ui.button.css", "~/Content/themes/base/jquery.ui.dialog.css", "~/Content/themes/base/jquery.ui.slider.css", "~/Content/themes/base/jquery.ui.tabs.css", "~/Content/themes/base/jquery.ui.datepicker.css", "~/Content/themes/base/jquery.ui.progressbar.css", "~/Content/themes/base/jquery.ui.theme.css")); } }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邵阳市| 祁连县| 萍乡市| 玉田县| 上杭县| 孝义市| 凤凰县| 潼关县| 海淀区| 冀州市| 太保市| 广平县| 大化| 荔波县| 拉孜县| 琼海市| 宁化县| 兰溪市| 高台县| 莎车县| 临朐县| 兴文县| 枞阳县| 平阴县| 海南省| 巫山县| 开平市| 衡山县| 乐至县| 平顶山市| 宁海县| 咸宁市| 文登市| 涡阳县| 山阴县| 十堰市| 邵阳县| 华安县| 玉环县| 安国市| 延长县|