zoukankan      html  css  js  c++  java
  • [转载]Net WebService(也包括一般意义的 HttpWebRequest) 超时设置

    .Net WebService(也包括一般意义的 HttpWebRequest) 超时设置

    1. 服务器端设置超时

    web.config 的 system.web 里添加如下配置项:

    < httpRuntime
    executionTimeout="30"
    />

    以上时间单位是秒.

    记得要把 web.config 的 debug 模式关闭:

    < compilation
    defaultLanguage="c#"
    debug="false"
    />

    如果 debug 模式没有关闭, executionTimeout 会被忽略. 这时候, 如果应用是在单步跟踪的模式下, 根据经验, 超时时间大约是 90 秒(在 machine.config 里设置的, 我猜的^_^), 如果不是在单步跟踪的模式下, 超时时间可能是 20 分钟(也是我猜的, 因为其 session 的缺省超时时间是 20 分钟, 哈). 我懒得找微软的文档作进一步的求证了, 反正我用不着知道 debug 模式下的确切超时时间.

    2. 客户端设置超时

    在 WebService 的客户端代理程序(用 wsdl.exe 生成)里设置 Request 超时时间, 单位是毫秒:
    protected override WebRequest GetWebRequest(Uri uri)
    {
    HttpWebRequest wr = (HttpWebRequest)base.GetWebRequest( uri );
    wr.Timeout = 30*1000;
    return wr;
    }

  • 相关阅读:
    【bzoj4066】 简单题
    【bzoj1941】 Sdoi2010—Hide and Seek
    【bzoj2648】 SJY摆棋子
    【poj2154】 Color
    【poj2409】 Let it Bead
    【codevs1106】 篝火晚会
    【poj3270】 Cow Sorting
    【bzoj1004】 HNOI2008—Cards
    【bzoj3143】 Hnoi2013—游走
    【codeforces 749E】 Inversions After Shuffle
  • 原文地址:https://www.cnblogs.com/fx2008/p/2248127.html
Copyright © 2011-2022 走看看