【问题标题】:Fiddler not capturing local traffic from webClient on LINQPadFiddler 未从 LINQPad 上的 webClient 捕获本地流量
【发布时间】:2014-10-03 16:27:24
【问题描述】:

团队,

我有以下来自 LINQPad 的简单 WebClient 调用。我如何尝试提琴手只是拒绝捕捉。 我只是走投无路了。我尝试了 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"; 

【问题讨论】:

    标签: asp.net-mvc asp.net-web-api fiddler


    【解决方案1】:

    当你尝试时,你还没有解释 实际发生了什么

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

    1. 请求成功,说明Fiddler抓到了流量
    2. 请求失败,这意味着您的客户端未正确配置为代理其请求。

    【讨论】:

    • 您好 Eric,您更改字符串 URL 的建议起到了作用。以下终于奏效了。字符串 url = "localhost.fiddler:21531/api/employees/12345";一个多小时以来,我只在操作 Proxy = new WebProxy("127.0.0.1", 8888);我提到的不同组合。非常感谢。
    • 我正在使用带有 HttpClient 的 LinqPad。我有:var webAddr = "http://localhost.fiddler:53733/"; 但 Fiddler 仍然什么也没看到。
    • @MKenyonII - 见上面的答案。如果请求失败,则表示您的代理未正确配置。
    猜你喜欢
    • 2018-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多