Problem with "~" in routing file instead of ".."

54 views Asked by At

I'm working on a asp.net web-form website in which I use ../ for routing files like js files, styles, etc. When I decided to apply ScriptBundle and replace ~/ instead ../ the website didn't work at.
js file completely are loaded on browser but they didn't work.

This is my code before ScriptBundle that work perfectly:

<!-- Page Scripts Starts -->
<script src="../Script/jquery.min.js"></script>
<script src="../Script/jquery.colorpanel.js"></script>
<script src="../Script/bootstrap.min.js"></script>
<script src="../Script/jquery.flexslider.js"></script>
<script src="../Script/bootstrap-datepicker.js"></script>
<script src="../Script/owl.carousel.min.js"></script>
<script src="../Script/custom-navigation.js"></script>
<script src="../Script/custom-flex.js"></script>
<script src="../Script/custom-owl.js"></script>
<script src="../Script/custom-date-picker.js"></script>
<!-- Page Scripts Ends -->

and this is after ScriptBundle:

<!-- Page Scripts Starts -->
        <%: Scripts.Render("~/Script/js") %>
<!-- Page Scripts Ends -->

Cs file:

    bundles.Add(new ScriptBundle("~/Script/js").Include(
              "~/Script/bootstrap-datepicker.js",
              "~/Script/bootstrap.min.js",
              "~/Script/custom-date-picker.js",
              "~/Script/custom-flex.js",
              "~/Script/custom-navigation.js",
              "~/Script/custom-owl.js",
              "~/Script/jquery.colorpanel.js",
              "~/Script/jquery.flexslider.js",
              "~/Script/jquery.min.js",
              "~/Script/owl.carousel.min.js"));
1

There are 1 answers

0
Sani Huttunen On BEST ANSWER

That is beacuse the order of the script files (in .cs) is wrong. jquery.min.js should most likely be first. Change the order so that it is the same as per your working example. Since atleast all jquery.*.js files uses jquery.min.js they must be loaded after jquery.min.js.