asp.net - 在 Fiddler 中看不到 WebClient post 请求

标签 asp.net .net webforms webclient fiddler

我有一个 ASP.NET WebForms 应用程序(发送方),它将 WebClient post 请求发送到同一开发计算机上的另一个 ASP.NET 应用程序(接收方)。 WebClient 帖子是通过单击发件人应用程序中的按钮启动的。这是一个测试应用程序,表单只有按钮。我可以从 Fiddler 中的按钮看到帖子,但看不到来自 WebClient 方法的帖子请求。 为什么?

我知道 WebClient 帖子成功运行,因为在接收方应用程序中命中了断点,并且 Forms 集合具有来自发送方应用程序的 WebClient 请求的输入字段的值。 (使用Windows 8.1)

更新这是通话:

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 和 IE(版本 9 之前)不会通过任何代理向本地主机发送请求。有 3 种可能的解决方案:

  1. 使用计算机名称或主机名:http://<machine name>/testform/default.aspx
  2. 添加ipv4.fiddler到网址:http://localhost.fiddler/testform/default.aspx
  3. 向 fiddler 添加自定义规则:
static function OnBeforeRequest(oSession:Fiddler.Session){ 
    if (oSession.HostnameIs("MYAPP")) { 
        oSession.host = "<put your ip address and port here>"; 
    } 
}

那么你应该能够通过 http://myapp/testform/default.aspx 捕获流量

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

关于asp.net - 在 Fiddler 中看不到 WebClient post 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25836655/

相关文章:

c# - ASP.NET -> 同步调用 JavaScript 函数

javascript - IE 不为 GET 表单上的电子邮件输入传递 @ 符号

c# - 如何在 Datalist 中使用 HiddenField 获取动态 id

c# - 避免域模型中的循环引用

c# - .NET 未检测到任何 SQL Server 实例

c# - 函数定义,C 到 .NET

c# - Asp.net WebForms DropDownList - 具有不同值和显示文本的控件 (DataValueField/DataTextField)

javascript - 在不同的 javascript 窗口之间进行对话?

asp.net - 如何在 MVC3 .net 中实现 DotNetOpenAuth 作为 Oauth 提供者?

c# - JsonServiceClient 不使用放置在 cookiecontainer 中的 cookie