Simon Larsen Simon Larsen - 1 month ago 8
ASP.NET (C#) Question

old jquery version is automatically included in asp.net webforms

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.

Answer

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
        });