Download AjaxControlToolkit scripts from Microsoft CDN using ScriptManager / ToolkitManager

I know that there is another question asking the same thing, but it has not received any attention for several months: https://stackoverflow.com/questions/3786088/how-to-force-ajax-control-toolkit- scripts-loading-from-cdn

I upgraded my site to .NET4 and now I am using tagManager EnableCDN = "true". My Ajax scripts reference the Microsoft CDN exactly as I expected, but I cannot get my AjaxControlToolkit scripts to boot from the CDN. Instead, they are all loaded locally through ScriptResource.axd.

I know where the CDN files are, and I know that every time I use the control, I can refer to these files, but I have a lot of legacy code that loads on its own from the scriptwriter, just pulling out ScriptResource.axd.

Any suggestions on how to get management tool scripts to boot from CDN? I already have standard WebForms.js etc.

Let me know if there is anything that I can clarify, here is the script manager that I use: (I tried toolkitscriptmanager)

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" 
EnableCdn="true" EnableScriptLocalization="false" 
LoadScriptsBeforeUI="false" EnableViewState="false" />
+3
source share
4 answers

If the assembly does not specify the CDN path in its WebResourceAttributes attributes, EnableCDN will not know where to go. So here it is.

CDN, CDN, . , ACT CDN . , , 40412, , : http://www.asp.net/ajaxlibrary/CDNACT40412.ashx

( ):
http://weblogs.asp.net/infinitiesloop/archive/2009/11/23/asp-net-4-0-scriptmanager-improvements.aspx

, :

void Application_Start(object sender, EventArgs e) {
    ScriptManager.ScriptResourceMapping.AddDefinition("Foo.js", typeof(FooControl).Assembly, new ScriptResourceDefinition {
        ResourceName = "Foo.js",
        ResourceAssembly = typeof(FooControl).Assembly,
        CdnPath = "http://yadda-yadda/foo.js",
        CdnDebugPath = "http://yadda-yadda/foo.debug.js",
    });
}

. , , Foo.dll. script "Foo.js" ( .js ). , asp: ScriptReferences ( ) ScriptResource.axd. WebResourceAttribute script CDN, , CdnMode.

, script. . script ( " ", ). AddDefinition .

, , , script. , , cdn.. .

ResourceName ResourceAssembly , script , . , CDN . : (1) , CDN, (2) , (foo.debug.js) LOCALIZED ( , foo.fr-FR.js) , CDN ( ). ( , , ).

CdnPath CdnDebugPath , . EnableCdn !

ScriptMapping, , script, . , script .

... AjaxControlToolkit?

script . , . script. 1 . , - , , , .

- 1 2 ACT, , . , .

, , , script ( " " )? , , System.Web.Extensions "AjaxFrameworkAssembly" . , , . "AjaxFrameworkAssembly" ? , System.Web.Extensions , "AjaxFrameworkAssembly" . , " , ms ajax, System.Web.Extensions". ACT , "" , System.Web.Extensions. , . , , , presto, , . , , . , , .

InfinitiesLoop. :)

+11

, , , ACT- CDN, , .

: http://ajax.aspnetcdn.com/ajax/act/40412/

, ACT- MicrosoftAjaxCore.js: http://ajax.aspnetcdn.com/ajax/act/40412/MicrosoftAjaxCore.js

, , - , , ToolkitScriptManager, - Global.asax. , /​​ .

        ScriptManager.ScriptResourceMapping.AddDefinition("MicrosoftAjaxCore.js", new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxCore.js",
            CdnPath = "http://ajax.aspnetcdn.com/ajax/act/40412/MicrosoftAjaxCore.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/act/40412/MicrosoftAjaxCore.debug.js"
        });

FrameworkMode = "" , , ACT-, System.Web.Extensions. , ACT.

                <asp:ScriptReference Name="MicrosoftAjaxCore.js" Assembly="AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
                <asp:ScriptReference Name="MicrosoftAjaxComponentModel.js" Assembly="AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"  />
                <asp:ScriptReference Name="MicrosoftAjaxSerialization.js" Assembly="AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"  />
                <asp:ScriptReference Name="MicrosoftAjaxNetwork.js" Assembly="AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"  />
                <asp:ScriptReference Name="MicrosoftAjaxWebServices.js" Assembly="AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"  />
                <asp:ScriptReference Name="MicrosoftAjaxWebForms.js" Assembly="AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
+2

: . , , script ajaxtoolkit ScriptResource.axd.

, , script ( Microsoft CDN), , / , .

+1

, InfinitiesLoop (http://weblogs.asp.net/infinitiesloop/archive/2009/11/23/asp-net-4-0-scriptmanager -improvements.aspx), , .

, WebResourceAttribute: CdnPath. , URL. .

[: WebResource ( "Foo.js", "application/x-javascript", CdnPath = "http://foo.com/foo/bar/foo.js" )]

ScriptManager , EnableCdn true ScriptResource.axd . . , CDN . , script, , .

0
source

Source: https://habr.com/ru/post/1792925/


All Articles