当我尝试在IIS中启动网站时出错:值不能为空.参数名称:key

本文关键字:不能 参数 key 出错 IIS 网站 启动 | 更新日期: 2023-09-27 18:16:28

我尝试在IIS中启动网站并得到此错误。我不知道是什么原因,因为这个网站是别人创建的,不是我。

堆栈跟踪:

`System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +14370237
   System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value) +20
   Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.GetLiteralTraceData(LiteralControl literal, TraceData& data) +71
   Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.GetTraceData(Object renderedObject) +220
   Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.EndRendering(TextWriter writer, Object renderedObject) +47
   System.Web.UI.RenderTraceListenerList.EndRendering(TextWriter writer, Object renderedObject) +90
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +12372803
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +246
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +246
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +246
   System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer) +331
   System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer) +114
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +246
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +151
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +49
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +246
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +246
   System.Web.UI.Page.Render(HtmlTextWriter writer) +40
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5363`

当我尝试在IIS中启动网站时出错:值不能为空.参数名称:key

如果您的服务器控件过期或版本较旧,则PageInspector通常会起作用。如果你使用的是外部ASP。. NET服务器控件,请尝试升级它们。

如果你有合适的解决方法,那么你可以禁用页面检查器,如下所示:

<appSettings>
    <add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />
</appSettings>

有一个类似的问题,虽然@raja nadar的回答为我修复了它,但这不是真正的原因(或者事实证明是真正的修复)。

问题是:

optimizeCompilations="true"
添加

<add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />

将其踢入完全重新编译,其中切换为false/true可以在同事的机器上修复此问题。

似乎我修改了一些不是在根没有触发相关DLL的重新编译的东西。

我在VS2017社区版中面临同样的问题。下面是观察,上面的帖子对我很有用。它只会发生,当你的visual studio更新,(https://blogs.msdn.microsoft.com/davidebb/2009/04/15/a-new-flag-to-optimize-asp-net-compilation-behavior/)要打开此开关,请将其添加到编译部分:

<compilation optimizeCompilations="true">

或添加

<add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />

如上所述