AZOOZ
AZOOZ

Reputation: 59

Bundles not working in my ASP.NET website

I wrote this code:

BundleConfig.cs

    public static void RegisterBundles(BundleCollection bundles)
    {

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/js/jquery-{version}.min.js")); // bundle jQuery

        bundles.Add(new StyleBundle("~/bundles/bootstrapcss").Include(
            "~/css/bootstrap.min.css"));
        bundles.Add(new ScriptBundle("~/bundles/bootstrapjs").Include(
           "~/js/bootstrap.min.js")); // bundle jquery

        bundles.Add(new StyleBundle("~/bundles/css").Include(
            "~/css/MYStyle.min.css"
            , "~/css/font-awesome.min.css"
            , "~/css/JF-flat.min.css"));
        BundleTable.EnableOptimizations = true;
    }

 <% Styles.Render("~/bundles/bootstrapcss");%>
 <% Styles.Render("~/bundles/css");%> <% Scripts.Render("~/bundles/jquery"); %> 
<% Scripts.Render("~/bundles/jquery"); %>

and these settings in the web.config:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="BundleModule"/>
        <add name="BundleModule" 
             type="System.Web.Optimization.BundleModule"/>
    </modules>
</system.webServer>

Even I change Debug=false.

I added this code also in Global.asax.cs :

void Application_Start(object sender, EventArgs e) { // // Code that runs on application startup // // Application["visitor"] = 0; BundleConfig.RegisterBundles(BundleTable.Bundles); }

I want fix this issue as soon as possible.

Upvotes: 2

Views: 992

Answers (2)

AZOOZ
AZOOZ

Reputation: 59

I found a solution thank God.

The solution is just this:

<%: Styles.Render("~/bundles/bootstrapcss")%>
<%: Styles.Render("~/bundles/css") %>
<%: Scripts.Render("~/bundles/jquery") %>
<%: Scripts.Render("~/bundles/bootstrapjs") %>

Upvotes: 2

FindOutIslamNow
FindOutIslamNow

Reputation: 1236

Did you forget to render some style / script bundles?

<% Scripts.Render("~/bundles/jquery") %>

Upvotes: 0

Related Questions