vmalyuta
vmalyuta

Reputation: 117

Capturing traffic by fiddler in .net 4.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?

Upvotes: 0

Views: 1533

Answers (1)

Nikanos Polykarpou
Nikanos Polykarpou

Reputation: 391

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

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:

System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse()

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);
            }
        }
    }
}

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

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

Upvotes: 1

Related Questions