I used Visual Studio 2012 and the built-in template (under Add -> New Project) to create a brand new ASP.NET Web Forms web application project. Inside the Site.Master page provided by default I see some markup targeting JQuery, which is included down below.
How does ASP.NET figure out the paths necessary to include JQuery, given the following mark up?
<asp:ScriptManager runat="server">
<Scripts>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
I don't see anywhere a config file or code that would resolve jquery to "~/Scripts/jquery-1.7.1.js". I see a packages.config file but it doesn't explicitly describe the path that must be being calculated somehow.
Does anyone know how the path to JQuery's javascript file is resolved at runtime?
Inside the Microsoft.ScriptManager.WebForms PreAppStartCode, it has:
System.Web.UI.ScriptManager.ScriptResourceMapping.AddDefinition("WebFormsBundle", new ScriptResourceDefinition
{
Path = "~/bundles/WebFormsJs",
CdnPath = "http://ajax.aspnetcdn.com/ajax/4.5/6/WebFormsBundle.js",
LoadSuccessExpression="window.WebForm_PostBackOptions",
CdnSupportsSecureConnection = true
});
This is what hooks up to the declarations from the script reference:
<asp:ScriptReference Name="WebFormsBundle" />
And also does the deduplication because the ScriptReference path is the same as the path for the files inside of your bundle which should be registered inside of BundleConfig.cs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With