小编ign*_*ool的帖子

64位Windows上的HttpWebRequest GetResponse延迟

我最近尝试在64位版本的Windows上运行.NET应用程序,并且惊讶地注意到我HttpWebRequest.GetResponse()在本地网络上对Web服务的所有调用都在谈论(大约500ms)时间.以下是有关我的测试设置的一些信息:

  • .NET 3.5
  • Windows Vista Home Premium 32位,Windows Vista Business 64位和Windows Server 2008 64位.

测试代码是MSDN文章中HttpWebRequest.GetResponse描述的示例的略微修改版本.我执行的唯一修改只是一个循环,因此我可以计算10个连续调用和基本身份验证,因为我定位的Web服务需要身份验证:

using System;
using System.Diagnostics;
using System.Net;
using System.Text;
using System.IO;

public class Program
{
    // Specify the URL to receive the request.
    public static void Main (string[] args)
    {
        CredentialCache crCache = null;
        Stopwatch s = new Stopwatch();
        for (int i = 0; i < 10; i++)
        {
            s.Reset();
            s.Start();
            HttpWebRequest request = 
                (HttpWebRequest)WebRequest.Create (args[0]);

            // Set some reasonable limits …
Run Code Online (Sandbox Code Playgroud)

.net 64-bit httpwebrequest

15
推荐指数
2
解决办法
4858
查看次数

标签 统计

.net ×1

64-bit ×1

httpwebrequest ×1