I am new to this concept, this is my first project implementing the optimization concept with (Bundling & minification)
Just i am trying to test with simple js & css
Test.aspx
<html>
<%@ import namespace="System.Web.Optimization" %>
<html>
<head runat="server">
<%: Scripts.Render("~/bundles/js") %>
<%: Styles.Render("~/bundles/css") %>
</head>
<body>
<form id="form1" runat="server">
<div>
<button id="tests">
testing</button>
</div>
</form>
</body>
</html>
Global.Asax look like this
protected void Application_Start(object sender, EventArgs e)
{
RegisterBundles(BundleTable.Bundles);
}
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/js").Include(
"~/script/jquery-1.8.2.min.js",
"~/script/s.js"));
bundles.Add(new StyleBundle("~/bundles/css").Include(
"~/css/master.css"));
BundleTable.EnableOptimizations = true;
}
the file are Bundling, but in Css i have some style to render in the webpage, it nothing appearing on this,
Sample like jquery files also
for more info abt this post, please check this..Click here
can you guide me to achieve this...
Your bundling is working, problem is you css are not working when bundled.
Change your style sheet bundle name to this:
bundles.Add(new StyleBundle("~/css/allcss").Include("~/css/master.css"));
This should solve your problem.
P.S. if you keep your css files in multiple folders, then create a bundle for each folder. You can use the IncludeFolder
method to make your job easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With