5中的提琴手捕获流量

5中的提琴手捕获流量

本文介绍了NET 4.5中的提琴手捕获流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2010上编写了一个简单的应用程序,该应用程序发送httpwebrequest,并且没有任何配置,fiddler捕获了此请求.但是之后,我安装了VS2012并运行了提琴手,当我发送请求时,我遇到了异常操作超时",并且没有捕获到请求.当我关闭提琴手时,所有请求都将发送. 我删除了VS2012和.net Framework 4.5.在该请求之后,发送并由提琴手捕获.
为什么安装.net4.5时提琴手无法捕获流量?

I wrote simple application on VS2010 that send httpwebrequest and without any configurations fiddler is captures this request. But after, I installed VS2012 and run fiddler, and when i send request i have exception "Operation timed out" and request is no captured. When i close fiddler all requests are sends. I delete VS2012 and .net framework 4.5. After that request are sends and fiddler capturing them.
Why fiddler dont't capture traffic when .net4.5 installed?

推荐答案

您是否有机会尝试设置主机属性?这可能是导致您出现问题的原因.

Did you by any chance try to set the Host property of the HttpWebRequest?This may be the cause of your problem.

我还安装了.NET 4.5,并遇到了相同的情况.当提琴手正在运行并且充当代理时,我收到相同的错误.错误是:

I have also .NET 4.5 installed and experience the same situation.I get the same error when fiddler is running and is acting as a proxy. The error is:

以下是重现该问题的简单示例:

Here is a trivial sample that reproduces the problem:

using System;
using System.IO;
using System.Net;

namespace WebRequestTest
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
            request.Host = "www.microsoft.com";//If I comment this line, capturing with fiddler works OK.
            request.Method = "GET";
            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0";

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            using (Stream stream = response.GetResponseStream())
            using (StreamReader sr = new StreamReader(stream))
            {
                string content = sr.ReadToEnd();
                Console.WriteLine(content);
            }
        }
    }
}

就我而言,我只需要注释request.Host="www.microsoft.com"行,一切正常.

In my case I just had to comment the request.Host="www.microsoft.com" line and everything worked OK.

我怀疑使用非提琴手的HTTP代理时也会发生相同的行为,但是我尚未对其进行测试.

I suspect same behavior will occur when using an HTTP proxy other than fiddler, but I have not tested it though.

这篇关于NET 4.5中的提琴手捕获流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 15:48