ScriptManager的并发问题

时间:2019-07-15 09:59:15

标签: c# asp.net webforms scriptmanager clientscriptmanager

我知道Asp.Net WebForms相当古老且过时,但是我希望仍然有人在维护这样的旧代码库...

在对我们的网站进行负载测试时,我看到了奇怪的错误,所有这些似乎都归结为.Net处理页面上脚本引用的方式中的并发问题。我可以在ScriptManager throws "An entry with the same key already exists."上看到有关该问题的报告,可以追溯到2007年。

我正在使用.Net 4.7.2,这是一个在负载下发生的错误的示例:

错误1 ArgumentException:具有相同键的条目已存在。

   at System.Collections.Specialized.ListDictionary.Add(Object key, Object value)
   at System.Web.UI.ClientScriptManager.RegisterScriptBlock(ScriptKey key, String script, ListDictionary& scriptBlocks, ArrayList& scriptList, Boolean needsScriptTags)
   at System.Web.UI.ClientScriptManager.RegisterScriptBlock(ScriptKey key, String script, ClientAPIRegisterType type)
   at System.Web.UI.ScriptRegistrationManager.RegisterClientScriptInclude(Control control, Type type, String key, String url)
   at System.Web.UI.ScriptManager.RegisterClientScriptIncludeInternal(Control control, Type type, String key, String url)
   at System.Web.UI.ScriptManager.RegisterUniqueScripts(List'1 uniqueScripts)
   at System.Web.UI.ScriptManager.RegisterScripts()
   at System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e)
   at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

错误2 IndexOutOfRangeException:索引超出数组的范围。

   at System.Collections.Generic.List'1.Add(T item)
   at System.Web.UI.ScriptRegistrationManager.RegisterClientScriptInclude(Control control, Type type, String key, String url)
   at System.Web.UI.ScriptManager.RegisterClientScriptIncludeInternal(Control control, Type type, String key, String url)
   at System.Web.UI.ScriptManager.RegisterUniqueScripts(List'1 uniqueScripts)
   at System.Web.UI.ScriptManager.RegisterScripts()
   at System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e)
   at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

错误3 对象引用未设置为对象的实例。

   at System.Web.UI.ClientScriptManager.RenderRegisteredScripts(HtmlTextWriter writer, ArrayList scripts, Boolean checkForScriptManagerRegistrations)
   at System.Web.UI.ClientScriptManager.RenderClientScriptBlocks(HtmlTextWriter writer)
   at System.Web.UI.Page.BeginFormRender(HtmlTextWriter writer, String formUniqueID)
   at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
   at ASP.masters_site_master.__RenderHtml(HtmlTextWriter __w, Control parameterContainer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

从.Net看source code,这些错误可能发生的唯一可能性是多线程。我发现ScriptManagerClientScriptManager内部的某些字段和方法是静态的,尽管我还没有确定会发生并发的肯定情况,但这也许可以解释这一点。

有人看到,解决或解决了这个问题吗?

0 个答案:

没有答案