3

I am using latest Chrome browser, ASP.NET MVC 4, "jQuery" version="2.0.3", "jQuery.Validation" version="1.11.1", Microsoft.jQuery.Unobtrusive.Ajax" version="2.0.30506.0", and Microsoft.jQuery.Unobtrusive.Validation" version="2.0.30506.0".

My debug and test systems (bundling and minification off) work fine. On my production system, even though the username and password are remembered, and already in the edit boxes, login always fails client side validation (user name required and password required), unless I check the remember me box again, or fully replace the username and password. Login works as expected if I turn off bundling and minification production by setting "BundleTable.EnableOptimizations = false" in the global.asx.cs file.

These are my bundles:

            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

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

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

and this is how I reference them at the end of the 'head' section along with other scripts:

        @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/jquery", "~/bundles/jqueryval")

I can't figure out how to debug this using Chrome F12 tools as it only happens on the prod system after deployed and only when bundling and minification are turned on.

If I add the scripts to the end of the 'body' as below, as well as after the 'body', and in both cases, I get a totally empty page though it seems to have all the source.

    <body class="Body">
    @RenderBody()

    @* load scripts last *@

    @* bring in script bundles *@
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/SignalR")

    <!--Reference the autogenerated SignalR hub script. -->
    <script src="~/signalr/hubs"></script>

    @Html.DevExpress().GetScripts(
    new Script { ExtensionSuite = ExtensionSuite.NavigationAndLayout },
    new Script { ExtensionSuite = ExtensionSuite.HtmlEditor },
    new Script { ExtensionSuite = ExtensionSuite.GridView },
    new Script { ExtensionSuite = ExtensionSuite.PivotGrid },
    new Script { ExtensionSuite = ExtensionSuite.Editors },
    new Script { ExtensionSuite = ExtensionSuite.Chart },
    new Script { ExtensionSuite = ExtensionSuite.Report },
    new Script { ExtensionSuite = ExtensionSuite.Scheduler },
    new Script { ExtensionSuite = ExtensionSuite.TreeList }
    )

    @* user scripts *@
    @RenderSection("scripts", required: false)
</body>
Odi
  • 6,916
  • 3
  • 34
  • 52
Dave
  • 1,822
  • 2
  • 27
  • 36
  • Did you checked out if every scrip is included in the page after render? Checkout for missing files in chrome debug. – Fals Sep 26 '13 at 19:15
  • Another thing, render jquery and jqueryval after the body, and try to spread this out: @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryval") – Fals Sep 26 '13 at 19:20
  • Are you rendering the scripts on a layout page or on the view its self? – Botonomous Sep 26 '13 at 19:28
  • The bundles are included in a layout page, ahead of the body, and the scripts are all present when bundling is turned off, so presumably are there when bundling is turned on. I will try to verify this. Will also try to separate jquery from jqueryval and will report back. Thx. – Dave Sep 26 '13 at 20:53
  • The bundles are included in a layout page, ahead of the body, and the scripts are all present when bundling is turned on or off, though when on, the actual scripts seems a bit different than the .min.js version I have in regards to some var names. When I added to the bottom of the I get a totally blank page though it has all the source. I updated the main question to show what I did. – Dave Sep 26 '13 at 21:12
  • Anyone have any other ideas? Bad .min version of the jQuery script? – Dave Sep 27 '13 at 20:53

1 Answers1

1

Check that you are not bundling any .min scripts (you can't minify a minified version of a file).

You can still include the .min files of your app if you create an ignore list and specify MVC the extensions of the files you want the bundling method to ignore. For more references, check this:

Bundler not including .min files

Community
  • 1
  • 1
RainierMallol
  • 806
  • 1
  • 8
  • 24