Can't see WebClient post request in Fiddler

和自甴很熟 提交于 2019-12-24 00:56:33

问题


I have an ASP.NET WebForms app (sender) which sends a WebClient post request to another ASP.NET app (receiver) on the same dev machine. The WebClient post is initiated by clicking a button in the sender app. It's a test app and the form has only the button. I can see the post from the button in Fiddler but I don't see the post request from the WebClient method. Why?

I know the WebClient post runs successfully because the breakpoint is hit in the receiver app and the Forms collection has the value of the input field from the WebClient request from the sender app. (Using Windows 8.1)

Update This is the call:

using (var client = new WebClient())
{
    client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
    var data = "FirstName=John";
    var result = client.UploadString("http://localhost/testform/default.aspx", "POST", data);
    Console.WriteLine(result);
}

回答1:


.NET and IE(before version 9) are not sending requests to localhost through any proxies. There are 3 possible solutions:

  1. Use machine name or hostname: http://<machine name>/testform/default.aspx
  2. Add ipv4.fiddler to the URL: http://localhost.fiddler/testform/default.aspx
  3. Add custom rule to the fiddler:
static function OnBeforeRequest(oSession:Fiddler.Session){ 
    if (oSession.HostnameIs("MYAPP")) { 
        oSession.host = "<put your ip address and port here>"; 
    } 
}

Then you should be able to capture traffic through http://myapp/testform/default.aspx

Reference Problem: Traffic sent to http://localhost or http://127.0.0.1 is not captured.




回答2:


Could be multiple things. Here are some possibilities

  1. You have Fiddler set to filter to only show things from a particular process (or some other type of filter but process is the easiest one to accidentally turn on)
  2. You have not turned on HTTPS capture in Fiddler but this missing request is HTTPS (it's off by default)
  3. Your WebClient has a custom proxy configured and isn't pulling the default settings from IE


来源:https://stackoverflow.com/questions/25836655/cant-see-webclient-post-request-in-fiddler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!