old jquery version is automatically included in as

2020-04-08 01:01发布

问题:

I have a asp.net c# webforms project. In the output html in the div "aspNetHidden" is a link to

<script src="/Scripts/jquery-1.8.2.js" type="text/javascript"></script>

I cannot figure out how to remove this code. It's not in the master page file, and I can't seem to find it anywhere. I would like to use a newer version of jquery, and place the reference at the bottom of the page instead.

I suspect it's from one of the installed NuGet packages, but I can't figure out which one, and I think i need them all.

EDIT: If i create a new project and select ASP.NET Web Forms Application, the jquery link is there. I'm using visual studio express 2012.

EDIT 2: Found a solution - posted as an answer for others with similar problem to see.

回答1:

I found a solution. It's added by the scriptmanager, but can be overridden by adding the following in the global.asax. I don't know if I can disable it completely, but this works for me.

string str = "1.10.2";
        ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
        {
            Path = "~/js/jquery-" + str + ".min.js",
            DebugPath = "~/js/jquery-" + str + ".min.js",
            CdnPath = "http://code.jquery.com/jquery-" + str + ".min.js",
            CdnDebugPath = "http://code.jquery.com/jquery-" + str + ".min.js",
            CdnSupportsSecureConnection = true
        });


回答2:

I solve my problem by change version of jquery in packages.config

change

  <package id="AspNet.ScriptManager.jQuery" version="1.8.2" targetFramework="net45" />
 <package id="jQuery" version="1.8.2" targetFramework="net45" />

to

<package id="AspNet.ScriptManager.jQuery" version="2.1.4" targetFramework="net45" />
 <package id="jQuery" version="2.1.4" targetFramework="net45" />

my jquery version is 2.1.4