Asp.net mvc Fiddler未从LINQPad上的webClient捕获本地流量
团队 我有以下来自LINQPad的简单WebClient调用。无论我怎么尝试,提琴手都拒绝捕捉。 我只是走投无路。我尝试了localhost、localhost.(带点)、localhost.fiddler和我的机器名,而不是127.0.0.1。Fiddler根本不想捕捉到这一点。任何人都有自己的想法Asp.net mvc Fiddler未从LINQPad上的webClient捕获本地流量,asp.net-mvc,asp.net-web-api,fiddler,Asp.net Mvc,Asp.net Web Api,Fiddler,团队 我有以下来自LINQPad的简单WebClient调用。无论我怎么尝试,提琴手都拒绝捕捉。 我只是走投无路。我尝试了localhost、localhost.(带点)、localhost.fiddler和我的机器名,而不是127.0.0.1。Fiddler根本不想捕捉到这一点。任何人都有自己的想法 void Main() { CookieWebClient client = new CookieWebClient() { Proxy = new We
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";
你还没有解释当你尝试时会发生什么
NET Framework绕过对localhost
的任何HTTP/HTTPS请求的代理,因此必须使用localhost.fiddler
作为字符串url
中的主机。这样做时,有两种可能性:
嗨,Eric,你的建议改变了字符串URL。下面的方法终于奏效了。字符串url=“”;一个多小时以来,我只操纵Proxy=newwebproxy(“127.0.0.1”,8888);用我提到的不同的组合。非常感谢。我正在与一个HttpClient一起使用LinqPad。我有:
var-webAddr=”http://localhost.fiddler:53733/";但是提琴手仍然什么也看不见。@MKenyonII-见上面的答案。如果请求失败,则表示您的代理未正确配置。