6

Visual Studio 2012と組み込みのテンプレート([追加]-> [新しいプロジェクト]の下)を使用して、まったく新しいASP.NETWebフォームWebアプリケーションプロジェクトを作成しました。デフォルトで提供されるSite.Masterページ内に、JQueryをターゲットとするマークアップが表示されます。これは以下に含まれています。

次のマークアップを前提として、ASP.NETはJQueryを含めるために必要なパスをどのように把握しますか?

<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>

jqueryを「〜/ Scripts/jquery-1.7.1.js」に解決する構成ファイルまたはコードはどこにもありません。packages.configファイルが表示されますが、何らかの方法で計算する必要のあるパスが明示的に記述されていません。

JQueryのjavascriptファイルへのパスが実行時にどのように解決されるか知っている人はいますか?

4

1 に答える 1

4

Microsoft.ScriptManager.WebForms PreAppStartCode内には、次のものがあります。

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

これは、スクリプトリファレンスからの宣言に接続するものです。

<asp:ScriptReference Name="WebFormsBundle" />

また、ScriptReferenceパスは、BundleConfig.cs内に登録する必要があるバンドル内のファイルのパスと同じであるため、重複排除も実行されます。

于 2012-09-17T22:09:58.457 に答える