C# HttpClient不能与Fiddler一起工作
我已经通过论坛并尝试了这些技术,但Fiddler仍然无法捕获我的流量。任何帮助都会有帮助 下面是Fiddler,所以我的WebAPI服务器可以正常工作。我的客户恢复正常C# HttpClient不能与Fiddler一起工作,c#,asp.net-web-api,httpclient,fiddler,C#,Asp.net Web Api,Httpclient,Fiddler,我已经通过论坛并尝试了这些技术,但Fiddler仍然无法捕获我的流量。任何帮助都会有帮助 下面是Fiddler,所以我的WebAPI服务器可以正常工作。我的客户恢复正常 http://localhost:49305/api/Employee/12345 主机文件 #localhost name resolution is handled within DNS itself. #127.0.0.1 localhost #::1 localhost
http://localhost:49305/api/Employee/12345
主机文件
#localhost name resolution is handled within DNS itself.
#127.0.0.1 localhost
#::1 localhost
这是使用localhost时的一个已知问题 您的url是
http://localhost:49305
并且您需要将其更改为在localhost:http://localhost.fiddler:49305
完成此操作后,HttpClient的请求将出现在Fiddler中
请参阅此SO问题:这是使用localhost时的已知问题 您的url是
http://localhost:49305
并且您需要将其更改为在localhost:http://localhost.fiddler:49305
完成此操作后,HttpClient的请求将出现在Fiddler中
请查看此SO问题:您是否100%确定在Fiddler中没有显示“仅浏览器”过滤器(查看Fiddler窗口的左下角)…谢谢Alexi。。将“.fiddler”添加到localhost解决了这个问题。那就是“。现在Fiddler显示流量。你应该将其作为答案发布(并最终接受)。进一步(官方)详细信息:你是否100%确定Fiddler中没有显示“仅浏览器”过滤器(查看Fiddler窗口的左下角)…谢谢Alexi。。将“.fiddler”添加到localhost解决了这个问题。那就是“。现在Fiddler显示了交通流。你们应该把它作为答案发布(并最终接受它)。进一步(官方)细节:可能的副本
static async Task GoAny()
{
HttpClientHandler clntHand = new HttpClientHandler()
{
CookieContainer = new CookieContainer(),
Proxy = new WebProxy("http://localhost:8888", false),
UseProxy = true,
UseDefaultCredentials = false
};
HttpClient clnt = new HttpClient(clntHand)
{
BaseAddress = new Uri("http://localhost:49305")
};
clnt.DefaultRequestHeaders.Accept.Clear();
clnt.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage resp = await clnt.GetAsync("api/Employee/12345");
if (resp.StatusCode == System.Net.HttpStatusCode.OK)
{
string c = resp.Content.ToString();
}
}