【问题标题】:Does ServicePointManager.Expect100Continue = false remain set application-wide after setting it once?ServicePointManager.Expect100Continue = false 设置一次后是否保持设置应用程序范围?
【发布时间】:2014-02-11 12:09:56
【问题描述】:

我有以下代码:

ServicePointManager.Expect100Continue = false;

在我的主窗口表单frmMain_Load 事件中。我有许多表单和类,其中调用了不同的 Web 服务,但它们总是在完成 frmMain_Load 事件后调用。

那么,ServicePointManager.Expect100Continue 将在所有表单和类的所有 Web 服务调用中保持不变?还是我必须在每次 Web 服务调用时将其设置为 false

它是 C# 中的 .NET 2.0 桌面应用程序。

注意:很抱歉我发布了这样一个愚蠢的问题。我可以通过对该值设置监视来检查调试器。

【问题讨论】:

  • 查看调试器并在该值上设置监视,您就会知道。
  • 哦。是的。很抱歉发布了一个愚蠢的问题。

标签: c# .net class assemblies system.net


【解决方案1】:

可能不是答案。但您可以将 expect100Continue 值设置为您的 App.Config。 设置此项将应用于所有 Web 服务调用。您不需要在每个 web 服务调用上单独设置它。

放在Configuration->system.net->settings里面

  <system.net>
    <settings>
      <servicePointManager expect100Continue="false"/>
    </settings>
  </system.net>

注意:除非您决定忽略 TCP 100Continue 响应结果,否则请勿更改此设置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-26
    • 2012-09-18
    • 2011-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多