简体   繁体   中英

AjaxControlToolkit Unhandled Exceptions in Asp.net

I use a few different AjaxControlToolkit controls. The 4 I use mostly are FilteredTextBoxExtender, CalendarExtender, TextBoxWatermarkExtender, and MaskedEditExtender. Everything works fine once uploaded to the Development Server. However, once on the production server, I get about 3 to 5 emails daily of an unhandled exception and the AjaxControlToolkit is the thing that is always in question. From the looks of it, it usually happens when another control is clicked or if the page is just "sitting" there and not in use. It says that it "Could not Load AjaxControlToolkit.TextBoxWatermarkExtender" or something of that sort. It doesn't happen to everyone every single day, but enough to think that there is a problem and that it needs to be addressed. As the only developer, I have tried testing this out and the only way I have made it "crash" was by making the page reload as much as possible. After about 100 clicks, it finally said that one of the AjaxControlToolkits extenders couldn't be loaded. Here is the last error message I have received today.

Source :

AjaxControlToolkit

Date and Time:

11/14/2013 1:45 PM

Message:

Could not load control AjaxControlToolkit.TextBoxWatermarkExtender. The script reference(s) of this control was not loaded correctly. If AjaxControlToolkit.config is used, probably this control is not registered properly.

Stack Trace:

at AjaxControlToolkit.ToolkitScriptManager.ValidateScriptReferences() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I have realized that when an error like this occurs, 8-10 times, it's on a PC that is running IE 8.

This is another error that occurs and also looks like that it has something to do with the AjaxControlToolkit because of the Stack Trace.

Source:

mscorlib

Date and Time:

11/14/2013 7:48 AM

Message:

Collection was modified; enumeration operation may not execute.

Stack Trace: at System.Collections.Generic.List 1.Enumerator.MoveNextRare() at System.Linq.Enumerable.All[TSource](IEnumerable 1 source, Func`2 predicate) at AjaxControlToolkit.ToolkitScriptManagerCombiner.LoadScriptReferences(HttpContextBase context, String[] bundles) at AjaxControlToolkit.ToolkitScriptManager.LoadScriptReferences(HttpContextBase context, String[] bundles, Boolean forCombineAndMinify) at AjaxControlToolkit.ToolkitScriptManager.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I have researched both of these types of errors but haven't found anything of use. I do know that the 2nd one is caused often when going through a loop and value was changed or something of that sort.

I am using the AjaxControlToolKit extenders in a few gridviews, so is it possible that it fails to load because they are in gridviews? Does anyone have a solution to this? My absolute last resort is to use jQuery to do these functions, but I do not want to do that. Any suggestions are greatly appreciated!

I've got the same random errors in production after upgrading a legacy project using an old AjaxControlToolkit (version 7.0725) from .NET 4.0 to .NET 4.8.

Could not load control AjaxControlToolkit.TabContainer. The script reference(s) of this control was not loaded correctly. If AjaxControlToolkit.config is used, probably this control is not registered properly.

After some troubleshooting we managed to fix the problem changing the code as follows:

From:

        <cc1:ToolkitScriptManager EnablePartialRendering="true" ScriptMode="Release" ID="TSM" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" AsyncPostBackTimeout="360000" LoadScriptsBeforeUI="false" CombineScripts="true" CombineScriptsHandlerUrl="~/CombineScriptsHandler.ashx">
            <CompositeScript>
                <Scripts>
                    <asp:ScriptReference Path="~/Scripts/jquery-3.2.1.slim.min.js" />
                    <asp:ScriptReference Path="~/bootstrap-3.3.7-dist/js/bootstrap.min.js" />
                </Scripts>
            </CompositeScript>
        </cc1:ToolkitScriptManager>

To:

        <cc1:ToolkitScriptManager ScriptMode="Release" ID="TSM" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" AsyncPostBackTimeout="360000" LoadScriptsBeforeUI="false" CombineScripts="False" />             

And moved the JS scripts files to <HEAD> :

<head>
    <script type="text/javascript" src="/Scripts/jquery-3.2.1.slim.min.js"></script>
    <script type="text/javascript" src="/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>

To summarize: removed the attributes EnablePartialRendering , CombineScriptsHandlerUrl and set CombineScripts to false ; and moved the individual scripts to the <head> section.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM