locked
css and js not loading RRS feed

  • Question

  • User780011528 posted

    I have developed a sample application in mv4

    it's works fine in visul studio

    But wen i moved to IIS 7.5 in my windows 7 the js & css is not loading

    I have  <compilation debug="true" targetFramework="4.0" /> in my working dir

    but i found  <compilation targetFramework="4.0" /> mean (debug="false") in publish dir

    i applied debug="true" to publish dir and issue solved any one have idea about this ? or how can i fix with debug="false"

    Tuesday, December 24, 2013 6:23 AM

Answers

  • User281315223 posted

    I don't recall encountering something like this before, however this blog post mentions possibly changing your directory that your files are stored in to "~/Bundles/CSS" and "~/Bundles/JS" for your CSS and Javascript files respectively (as opposed to using "~/CSS" and "~/JS"):

    public class BundleConfig
        {
            // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
            public static void RegisterBundles(BundleCollection bundles)
            {
                //This bundle is now within the "bundles" directory and the child directories are within a
                //"scripts" folder
                bundles.Add(new ScriptBundle("~/bundles/js").Include(
                            "~/scripts/js/jquery-1.10.2.js",
                            "~/scripts/js/bootstrap.js",
                            "~/scripts/js/modern-business.js"
                            ));
    
                //Notice the bundle is now targeting a "bundles" directory and the child resources are in a 
                //"styles" folder
                bundles.Add(new StyleBundle("~/bundles/css").Include("~/styles/css/bootstrap.css",
                    "~/styles/css/modern-business.css"
                    ));
            }
    
        }

    I would recommend giving that a try and see if it makes any difference as it may simply be a permissions issue with accessing that particular directory.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 26, 2013 8:35 AM

All replies

  • User281315223 posted

    Could you post the code of where you are currently calling your Javascript and CSS from? Are you using bundling or minification or simply referencing it through <link> and <script> elements respectively?

    Any additional details may be helpful in providing a more detailed answer.

    Tuesday, December 24, 2013 9:54 AM
  • User401360897 posted

    It look like your authentication denying the bundling url. Add some authorization rules

    Tuesday, December 24, 2013 12:29 PM
  • User780011528 posted
    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("~/js").Include(
                            "~/js/jquery-1.10.2.js",
                            "~/js/bootstrap.js",
                            "~/js/modern-business.js"
                            ));
                bundles.Add(new StyleBundle("~/css").Include("~/css/bootstrap.css",
                    "~/css/modern-business.css"
                    ));
    
                //bundles.Add(new StyleBundle("~/font-awesome").Include("~/font-awesome/css/font-awesome.min.css"));
            }
    
        }
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - My ASP.NET MVC Application</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
        @Styles.Render("~/css")
        <link href="@Url.Content("~/font-awesome/css/font-awesome.min.css")" rel="stylesheet" type="text/css">
    
    </head>
    <body>
    
        @Html.Partial("~/Views/Shared/_Navigation.cshtml")
        @RenderBody()
    
    
        @Html.Partial("~/Views/Shared/_Footer.cshtml")
        @Scripts.Render("~/js")    
    </body>
    </html>

    @Rion

    i have added config class & layout .cshtml for your reference ...

    any help will be really appreciate.

    Wednesday, December 25, 2013 1:05 AM
  • User780011528 posted

    @imran

    can you suggest me step or what thing i need to do in some detail .

    thx for your valuable suggestion.

    Wednesday, December 25, 2013 1:09 AM
  • User281315223 posted

    I don't recall encountering something like this before, however this blog post mentions possibly changing your directory that your files are stored in to "~/Bundles/CSS" and "~/Bundles/JS" for your CSS and Javascript files respectively (as opposed to using "~/CSS" and "~/JS"):

    public class BundleConfig
        {
            // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
            public static void RegisterBundles(BundleCollection bundles)
            {
                //This bundle is now within the "bundles" directory and the child directories are within a
                //"scripts" folder
                bundles.Add(new ScriptBundle("~/bundles/js").Include(
                            "~/scripts/js/jquery-1.10.2.js",
                            "~/scripts/js/bootstrap.js",
                            "~/scripts/js/modern-business.js"
                            ));
    
                //Notice the bundle is now targeting a "bundles" directory and the child resources are in a 
                //"styles" folder
                bundles.Add(new StyleBundle("~/bundles/css").Include("~/styles/css/bootstrap.css",
                    "~/styles/css/modern-business.css"
                    ));
            }
    
        }

    I would recommend giving that a try and see if it makes any difference as it may simply be a permissions issue with accessing that particular directory.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 26, 2013 8:35 AM
  • User780011528 posted

    Awesome man thanks for your reply
    really really appreciate your efforts .

    Smile

    Thursday, December 26, 2013 1:36 PM