0

I created an ASP.NET 4.7.1 WebForms web application project.

  • I removed all references to ~/Scripts/WebForms and ~/Scripts/WebForms/MsAjax in BundleConfig.cs.
  • I removed the NuGet packages for Microsoft.AspNet.ScriptManager.MSAjax and Microsoft.ScriptManager.MSAjax
  • I did an 'Edit > Find in Files' for "msajax" on the entire project, and nothing was found.

When I load any page on my site, ~/Scripts/WebForms/MsAjax/MicrosoftAjax.js and ~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js both still load. You can see them in HTML source and see that they get loaded in standard browser developer tools. I don't need them (as far as I know), and I don't want them wasting my bandwidth (over 140KB each pageload).

Obviously I can delete the files themselves, but then I just get HTTP 404 errors in my logs.

2
  • Check if these files are being served from browser cache? On chrome, open dev tools and then go to Network tab under which you can see if these js files are coming from cache. Commented Sep 9, 2018 at 4:00
  • @Sunil The .aspx page is not coming from cache. The .js files do come from cache after their first load (as they should). Commented Sep 9, 2018 at 5:02

1 Answer 1

1

To prevent MsAjax scripts from loading on page you need to set property AjaxFrameworkMode to Disabled

Markup

<asp:ScriptManager ID="ScriptManager" AjaxFrameworkMode="Disabled" ScriptMode="Release" runat="server">
    <CompositeScript ScriptMode="Release">
        <Scripts>
            <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" />
            <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" />
        </Scripts>
    </CompositeScript>
</asp:ScriptManager>

Code behind

ScriptManager.AjaxFrameworkMode = AjaxFrameworkMode.Disabled;
Sign up to request clarification or add additional context in comments.

1 Comment

@A_HREF Thanks for taking the time to answer an old question. It was still ongoing for me and this solved it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.