BundleConfig.cs not generating script references

I've been trying to get MVC 5 remote validation working in my little project. I've been reading enough about bundling in order to get the basics of it. I created a bundle for my jqueryval bundle, like so:

        bundles.Add(new ScriptBundle("~/bundles/jqueryval")
            .Include("~/Scripts/jquery-{version}.js")
            .Include("~/Scripts/jquery.validate.js")
            .Include("~/Scripts/jquery.validate.unobstrusive.js")
            );

However, when I publish the page, view source, the only scripts that are rendered, are as follows:

    <script src="/myApp/Scripts/jquery-2.1.0.js"></script>
    <script src="/myApp/Scripts/jquery.validate.js"></script>

notice that the query.validate.unobstrusive.js is missing. Now I know this is the key component in getting my validation working, because when I manually add the query.validate.unobstrusive.js to my view page like so:

  @section Scripts {
  @Scripts.Render("~/bundles/jquery")
  @Scripts.Render("~/bundles/jqueryval")
  <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript" />
  }

everything just works.

So now I'm left wondering, is there something I'm doing wrong with the Bundling? Why would this script not show up?

Answers


Do you have it enabled in your web.config?

<appSettings>
   <add key="ClientValidationEnabled" value="true" />
   <add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>

You won't need to include it in the BundleConfig.cs. Just make sure you havejquery.validate.unobstrusive.jsandjquery.validate.unobstrusive.min.jsin yourscriptsfolder


Need Your Help

Run CesiumJS with no server requirements

node.js cesium

I downloaded Cesiumjs-1.11 and ran the official Hello World tutorial.

Fastest way to store & retrieve translated text - database or flat file?

php database translation flat-file

I am working on upgrading our site to work in different languages.