question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can i bundle MicrosoftAjax.js and MicrosoftAjaxWebForms.js

See original GitHub issue

ASP.net 4.5, ajaxtoolkit 16.1 latest

I have downloaded both files into my script folder

Then i bundle them like this in the global.asax file

        void Application_Start(object sender, EventArgs e)
    {
        System.Web.Routing.RouteTable.Routes.Ignore("{resource}.axd/{*pathInfo}");
        RegisterRoutes(System.Web.Routing.RouteTable.Routes);

        var ajaxBundle = new ScriptBundle("~/bundles/MsAjaxJs");
        ajaxBundle.Include(new string[] { 
         "~/Scripts/MicrosoftAjax.js",
         "~/Scripts/MicrosoftAjaxWebForms.js"
    });


        BundleTable.EnableOptimizations = true;
        BundleTable.Bundles.Add(ajaxBundle);
    }

Then in my page i use them like this but it is not working

inside head

    <asp:PlaceHolder runat="server">
        <%:System.Web.Optimization.Styles.Render("~/bundles/MsAjaxJs") %>
    </asp:PlaceHolder>

Inside body

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">
    <asp:ScriptManager runat="server" ID="SC1" ScriptMode="Release" LoadScriptsBeforeUI="true"
        EnablePartialRendering="true">
        <Scripts>
            <asp:ScriptReference Path="~/bundles/MsAjaxJs" ScriptMode="Release" />
        </Scripts>
    </asp:ScriptManager>

But, I still see ScriptResource.axd files are called which contains MicrosoftAjax.js and MicrosoftAjaxWebForms.js with addition to my bundle file

toomany

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FurkanGozukaracommented, Jun 8, 2016

for example i tried like this but still that file is rendered twice

<asp:ScriptManager runat="server" ID="SC1" ScriptMode="Release" LoadScriptsBeforeUI="true" EnableCdn="false"
    EnablePartialRendering="true"> 
           <Scripts>
        <asp:ScriptReference Path="Scripts/MsAjax/MicrosoftAjaxWebForms.js" ScriptMode="Release" />
    </Scripts>
</asp:ScriptManager>

I want to use only my local file so i can modify and use it

0reactions
MikhailTymchukDXcommented, Jun 8, 2016

@FurkanGozukara If you check scripts content in browser’s debugger you will note that its content differs from the files that you put into the bundle. These scripts are added automatically from the System.Web.Extensions assembly when you place ScriptManager on your page.

You can not stop rendering them, but you can order ScriptManager to include it into your bundle. To do this, add this lines to your code:

ScriptManager.ScriptResourceMapping.AddDefinition("MsAjaxJs", new ScriptResourceDefinition {
    Path = "~/bundles/MsAjaxJs",
    CdnPath = "http://ajax.aspnetcdn.com/ajax/4.5.1/1/MsAjaxBundle.js",
    LoadSuccessExpression = "window.Sys",
    CdnSupportsSecureConnection = true
});

ScriptManager.ScriptResourceMapping.AddDefinition("MicrosoftAjax.js", new ScriptResourceDefinition {
    Path = "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
    CdnPath = "http://ajax.aspnetcdn.com/ajax/4.5.1/1/MicrosoftAjax.js",
    LoadSuccessExpression = "window.Sys && Sys._Application && Sys.Observer",
    CdnSupportsSecureConnection = true
});

ScriptManager.ScriptResourceMapping.AddDefinition("MicrosoftAjaxWebForms.js", new ScriptResourceDefinition {
    Path = "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js",
    CdnPath = "http://ajax.aspnetcdn.com/ajax/4.5.1/1/MicrosoftAjaxWebForms.js",
    LoadSuccessExpression = "window.Sys && Sys.WebForms",
    CdnSupportsSecureConnection = true
});

and replace ScriptReference Path attribute with Name attribute:

<asp:ScriptReference Name="MsAjaxJs" />
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can i bundle MicrosoftAjax.js and ... - MSDN
User1570265326 posted. ASP.net 4.5, ajaxtoolkit 16.1 latest. I have downloaded both files into my script folder. Then i bundle them like ...
Read more >
Getting pageLoad error in MicrosoftAjax.js - Stack Overflow
I am experiencing some errors with the raiseLoad function in MicrosoftAjax.js after they have logged on. MicrosoftAjax.js is loaded as a bundle
Read more >
[Solved] How to get rid of unwanted script tags - CodeProject
DebugPath = "~/Recursos/Scripts/Webforms/MSAjax/MicrosoftAjaxWebForms.js"; BundleConfig.RegisterBundles(BundleTable.Bundles); RouteConfig.
Read more >
MicrosoftAjax.js throwing an error in UI for ASP.NET AJAX
I have a RadGid with an inline edit from that contains a RadEditor on adding a new row the RadEditor is no longer...
Read more >
Where are the ASP.NET AJAX Library JavaScript files?
You don't need to install the Microsoft AJAX Library if you are using Visual Studio ... microsoftajax.js, microsoftajaxwebforms.js, microsoftajaxtimer.js, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found