Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Incorrect version of jQuery

$
0
0

I have created brand-new ASP.NET Core Web Application with standard template (File ->New -> Project -> .NET Core -> ASP.NET Core Web Application). I decided to update jQuery with Bower (Project -> Manage Bower Packages). The new jQuery version is 3.1.1. When I run app and went to source code (for instance, About page), I saw this in the bottom of the page:

<script src="/lib/jquery/dist/jquery.js"></script>

All is well and good, but when I follow that link I see:

jQuery JavaScript Library v2.2.0

What? Not the fresh version? I was hacking around my project to see whether I have some file with "v2.2.0" in it. I used Total Commander to scan files, but with no luck!
Then I thought "Perhaps, the source code of jQuery is somehow taken dynamically", and I saw this (in _Layout.cshtml):

<environment names="Development"><script src="~/lib/jquery/dist/jquery.js"></script><script src="~/lib/bootstrap/dist/js/bootstrap.js"></script><script src="~/js/site.js" asp-append-version="true"></script></environment><environment names="Staging,Production"><script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
            asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
            asp-fallback-test="window.jQuery"></script><script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/bootstrap.min.js"
            asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
            asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"></script><script src="~/js/site.min.js" asp-append-version="true"></script></environment>

Well, well, the picture seemed to become clearer! My app is ASPNETCORE_ENVIRONMENT is Development. The path to 3.1.1 jQuery is correct here. I decided to comment out the <environment names="Staging,Production">. I press Ctrl+F5 and.... see "jQuery v2.2.0". What? Again? This just drives me crazy. Here's Bower's json:

{"name": "asp.net","private": true,"dependencies": {"bootstrap": "v4.0.0-alpha.6","jquery": "3.1.1","jquery-validation": "1.16.0","jquery-validation-unobtrusive": "3.2.6"
  },"resolutions": {"jquery": "3.1.1","jquery-validation": "1.16.0","bootstrap": "v4.0.0-alpha.6"
  }
}

So, please. tell me - HOW TO MAKE ASP.NET GET CORRECT VERSIONS OF LIBRARIES? Thanks beforehand.


Viewing all articles
Browse latest Browse all 9386

Trending Articles