0

I want know why can not load All Js and Css a folder ? i have a folder for front views FrontTheme in this folder there is 2 folders css and js and i want load all js and css files in FrontTheme folder in bundles

my code is :

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
    //    bundles.Add(new ScriptBundle("~/Content/Admin/js").IncludeDirectory("~/Content/Admin/assets/", "*.js",true));
      //  bundles.Add(new StyleBundle("~/Content/Admin/css").IncludeDirectory("~/Content/Admin/assets/", "*.css",true));

        bundles.Add(new ScriptBundle("~/Content/FrontTheme/js")
            .IncludeDirectory("~/Content/FrontTheme/js", "*.js",true));
        bundles.Add(new StyleBundle("~/Content/FrontTheme/css")
            .IncludeDirectory("~/Content/FrontTheme/css", "*.css",false));


#if DEBUG
        BundleTable.EnableOptimizations = false;
#else
    BundleTable.EnableOptimizations = true;
#endif

and in view i use:

@Scripts.Render("~/Content/FrontTheme/js")
@Styles.Render("~/Content/FrontTheme/css")

but bundles not load css and js files and browser get me 403 forbidden status.

Where is it wrong? codes statuscode

---Update--- even i change bundles name to

~/Content/FrontThemejs

~/FrontTheme/js

~/FrontThemejs

~/Frontjs

Frontjs

~/123/js

~/Content/FrontThemecss

~/FrontTheme/css

~/FrontThemecss

~/Frontcss

Frontcss

~/456/css

but status code from 403 change to 404

Failed to load resource: the server responded with a status of 404 (Not Found)

arman
  • 125
  • 1
  • 12
  • 1
    Possible duplicate of [MVC4 style bundle giving 403](https://stackoverflow.com/questions/13673759/mvc4-style-bundle-giving-403) – adiga Oct 04 '17 at 17:51
  • 1
    As noted in @adiga's link, don't use a real folder name (`~/Content`) for the name of your bundle. It will cause these types of issues. – stephen.vakil Oct 04 '17 at 19:22
  • @stephen.vakil i change name to `~/FrontTheme/css` but same problem even change to `~/FrontThemecss` then error `Failed to load resource: the server responded with a status of 404 (Not Found)` – arman Oct 04 '17 at 19:49
  • Probably needs to have the same depth in the folder structure. Try `~/ScriptBundle/FrontTheme/js` and `~/StyleBundle/FrontTheme/css` maybe. Just a guess. – stephen.vakil Oct 04 '17 at 19:52
  • @stephen.vakil Doesn't work – arman Oct 04 '17 at 20:00

0 Answers0