累积更新KB4576947或KB4578974

时间:2020-09-29 15:31:33

标签: asp.net webforms httpcontext

更新-根据发现的新信息和对可复制样品的要求重写问题。

2020-09累积更新预览(适用于Windows 10 1903 x64版(KB4576947)的.NET Framework 3.5和4.8 )已于昨晚应用并进行了更改/中断我使用HttpContext.Current的代码,因为在我的代码中调用它时,它是null

已更新:现在是“非预览版”补丁 2020年10月13日-KB4578974 Windows 10、1903版,Windows Server 1903,Windows 10版的.NET Framework 3.5和4.8的累积更新,版本1909和Windows Server版本1909 会导致相同的问题。此补丁程序于2020年10月14日生效,并导致了相同的行为。

我通过测试没有应用此更新的计算机来确认这是问题所在。代码按预期工作,然后我应用了相同的更新,代码停止工作(与我的计算机执行失败的方式相同)。

此更新以某种方式更改了网站的初始化代码。下面是调用堆栈之间的区别。顶部堆栈来自未更新的工作计算机,底部堆栈来自故障计算机。

enter image description here

您可以看到更新/失败的计算机正在使用System.Web.dll!System.Web.Hosting.ProcessHost,而未更新且正在运行的计算机正在使用System.Web.dll!System.Web.Hosting.PipelineRuntime

要复制

  1. 创建一个新的C#Web窗体应用程序(只需选择asp.net/web窗体模板)。

  2. VS创建模板站点后,将ProgrammaticConfigurationProvider.cs文件添加到网站的根目录。

    using System.Configuration;
    using System.Linq;
    using System.Web;
    using System.Xml;
    
    namespace WebApplication1
    {
        public class ProgrammaticConfigurationProvider : ProtectedConfigurationProvider
        {
            public override XmlNode Decrypt( XmlNode encryptedNode )
            {
                var configElement = encryptedNode.ChildNodes.OfType<XmlElement>().First();
    
                switch ( configElement.Name )
                {
                    case "sessionState":
    
                        configElement.SetAttribute( "cookieName", "Test:" + ( HttpContext.Current.Session == null ? "Null" : "NotNull" ) );
                        break;
                }
    
                return configElement;
            }
    
            public override XmlNode Encrypt( XmlNode node ) => throw new System.NotImplementedException();
        }
    }
  1. 更新您的web.config文件,在configuration元素下添加以下内容:
    <configProtectedData defaultProvider="ProgrammaticConfigurationProvider">
        <providers>
            <add name="ProgrammaticConfigurationProvider" type="WebApplication1.ProgrammaticConfigurationProvider, WebApplication1" />
        </providers>
    </configProtectedData>
  1. 更新web.config,在system.web元素下添加以下内容:
    <sessionState configProtectionProvider="ProgrammaticConfigurationProvider">
        <EncryptedData>
            <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20" />
        </EncryptedData>
    </sessionState>

现在,当您运行时,HttpContext.Current方法内的Decrypt将为空。我们卸载了补丁程序,并且代码按预期再次开始工作。

问题

  1. 为什么我会获得补丁的预览版版本?我从来没有真正要求过。
  2. 我将从我的计算机上卸载此补丁,并假设它将再次开始工作,但是当该补丁的最终版本发布时,我想知道它的行为是否会相同(破坏我们网站上的100多个客户端站点) )还是对调用堆栈开始的更改看起来像是将要解决的某种错误?

1 个答案:

答案 0 :(得分:0)

我的Winform应用程序使用dotnet 4.6.2时存在类似问题。

由于安装了此更新,因此无法启动需要dotnet 4的应用程序。我可以在进程列表中看到该应用程序,一秒钟后,进程被“挂起”并且该应用程序已关闭...

在此更新之前,应用程序可以正常工作。

有人有主意吗?

谢谢

克里斯托夫

相关问题