不能看到提琴手WebClient的POST请求 [英] Can't see WebClient post request in Fiddler

查看:222
本文介绍了不能看到提琴手WebClient的POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET的WebForms应用程序(发送器),它发送一个Web客户端请求后在同一开发计算机上的另一个ASP.NET应用程序的(接收器)。 Web客户端后通过点击在发件人应用程序的一个按钮启动。这是一个测试应用程序和形式具有唯一的按钮。我可以看到在提琴手的按钮后,但我没有看到WebClient的方法POST请求。 为什么?

我知道Web客户端后成功运行,因为断点打在接收器的应用程序和Forms集合具有输入字段从发送者应用程序的Web客户端请求的值。 (使用Windows 8.1)

更新这是调用:

 使用(VAR的客户=新的Web客户端())
{
    client.Headers [Htt的prequestHeader.ContentType] =应用/的X WWW的形式urlen codeD;
    VAR数据=名字=约翰;
    VAR的结果= client.UploadString(HTTP://localhost/testform/default.aspx,POST,数据);
    Console.WriteLine(结果);
}
 

解决方案

.NET和IE浏览器(版本9之前)没有将请求发送到本地主机通过任何代理。有3种可能的解决方案:

  1. 使用机器名或主机名:的http://<机器名称> /testform/default.aspx
  2. 添加 ipv4.fiddler 来的网址:的http://localhost.fiddler/testform/default.aspx
  3. 添加自定义规则的小提琴手:

 静态函数OnBeforeRequest(oSession:Fiddler.Session){
    如果(oSession.HostnameIs(MYAPP)){
        oSession.host =<把你的IP地址和端口这里>中;
    }
}
 

然后,你应该能够通过 HTTP来获取流量://myapp/testform/default.aspx

问题:流量发送到http://本地主机或http://127.0.0.1不会捕获

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);
}

解决方案

.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.

这篇关于不能看到提琴手WebClient的POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆