Fiddler没有从LINQPad上的webClient捕获本地流量

Viv*_*Dev 2 asp.net-mvc fiddler asp.net-web-api

球队,

我从LINQPad调用了以下简单的WebClient.我怎么试过Fiddler只是拒绝捕获.我只是跑出了办法.我尝试了localhost,localhost.(带点),localhost.fiddler和我的机器名,而不是127.0.0.1.Fiddler根本没有兴趣捕获这个.任何人都有任何想法.

void Main()
{
    CookieWebClient client = new CookieWebClient() 
    {    
        Proxy = new WebProxy("127.0.0.1", 8888)    // Fiddler 
    };             
    Console.WriteLine(client.DownloadString(url)); // Cookie is created here 
    Console.WriteLine(client.DownloadString(url)); //  In this request, the cookie gets sent back to the web API
    Console.WriteLine("Done");
}

// Define other methods and classes here

public class CookieWebClient : WebClient 
{    
    private CookieContainer jar = new CookieContainer(); 
    protected override WebRequest GetWebRequest(Uri address)    
    {        
        WebRequest request = base.GetWebRequest(address);                     
        HttpWebRequest webRequest = request as HttpWebRequest;        
        if (webRequest != null)            
            webRequest.CookieContainer = jar;                     
        return request;    
    } 
}
string url = "http://localhost:21531/api/employees/12345"; 
Run Code Online (Sandbox Code Playgroud)

Eri*_*Law 8

你还没有解释当你尝试时会发生什么.

.NET Framework会绕过任何HTTP/HTTPS请求的代理localhost,因此您必须将其localhost.fiddler用作您的主机string url.当你这样做时,有两种可能性:

  1. 请求成功,这意味着Fiddler捕获流量
  2. 请求失败,这意味着您的客户端未正确配置为代理其请求.