After upgrading a asp.net Web forms project from. NET Framework 4.0 to the. NET Framework 4.5, it was found that Squishit unexpectedly raised HTTP error 500.0-internal Server error.
Squishit is an open source support asp.net js/css Packaging tool, Project address: Https://github.com/jetheredge/SquishIt, born earlier than Microsoft ASP.net Web Optimization Framework (System.Web.Optimization).
Because Squishit does not support the. NET Framework 4.5, it can only be discarded instead of System.Web.Optimization.
The following are steps for using System.Web.Optimization in the actual asp.net Web forms project:
1. Add a reference to the Microsoft ASP.net Web optimization framework via NuGet
2. Add BundleConfig.cs to the App_Code
Using System.Web.Optimization;
public class Bundleconfig
{public
static void Registerbundles (Bundlecollection bundles)
{
bundles. ADD (New Stylebundle ("~/bundles/news.css")
. Include ("~/common/screen_base.css",
"~/common/screen_news.css"));
Bundles. ADD (New Scriptbundle ("~/bundles/news.js")
. Include ("~/script/news_common.js",
"~/script/detail.js",
"~/script/share.js"));
}
3. Add the following code to the Application_Start of Global.asax:
Bundleconfig.registerbundles (System.Web.Optimization.BundleTable.Bundles);
4. Add the following JS/CSS reference code in. aspx:
5. Operation Result:
<link href= "/bundles/news.css?v=swiyzt7yghul_fjj5uctlq6nk499bbwg7ev8krgojn01" rel= "stylesheet"/>
<script src= "/bundles/news.js?v=h7kknxn83hakcjjjw2vnezbw_hhg-e5saponos_2cx41" ></script>
The main differences between System.Web.Optimization and Squishit:
Squishit will generate the actual file saved in the corresponding path.
System.Web.Optimization only generates bundle files in memory.
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/aspx/