PROBLEM SOLVED
Basically I'm used to starting my ASP.NET MVC4 projects with the Internet template. However this time I tried out with the Basic template. Now, I'm trying to manually add jQuery validation: I've installed the NuGet package jQuery.validation and have included it in my bundleconfig and _layout file.
Here's my bundleconfig:
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 here's how I include it in _layout:
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
Here are the js files being loaded per request:
http://localhost:10815/Scripts/jquery-2.0.3.js
http://localhost:10815/Scripts/jquery.unobtrusive-ajax.js
http://localhost:10815/Scripts/jquery.validate.js
http://localhost:10815/Scripts/jquery.validate.unobtrusive.js
In my controller I check if ModelState.IsValid and if not I return the view with the model - I've debugged the method and know for sure that the modelstate has errors.
And finally in my view file I have included:
@Html.ValidationSummary()
Which produces the following HTML output:
<div class="validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li>
</ul></div>
My issue is the fact that the validation summary doesn't change when I the controller returns the view - I don't know what's wrong though - what am I missing?
PROBLEM SOLVED - I used ajax which I've turned off now - works fine without ajax. I guess the validationsummary doesnt get reloaded thus no html is updated.