1

我知道 Asp.Net WebForms 已经过时了,但我希望周围还有人维护这样一个遗留代码库......

在对我们的网站进行负载测试时,我看到了一些奇怪的错误,这些错误似乎都归结为 .Net 处理页面上脚本引用的方式中的并发问题。我可以在这里看到 2007 年以来的问题报告:ScriptManager 抛出“已存在具有相同键的条目”。.

我正在使用 .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 的源代码,这些错误可能发生的唯一可能性是多线程。我看到一些字段和方法在内部是静态的ScriptManagerClientScriptManager这可以解释这一点,尽管我还没有找到会发生并发的确定场景。

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

4

0 回答 0