【问题标题】:How could I make Fiddler capture HTTP requests made by my MVC app to my ASP.NET Web API?如何让 Fiddler 捕获我的 MVC 应用程序向我的 ASP.NET Web API 发出的 HTTP 请求?
【发布时间】:2014-07-12 00:03:24
【问题描述】:

我有一个 ASP.NET MVC 应用程序,它使用 System.Net.HttpClient 类向 ASP.NET Web API 发出请求。当我开始调试它们时,Visual Studio 调试器将 MVC 应用程序(即客户端)和 ASP.NET Web API(即服务器)托管在 IIS Express 中。

我想让 Fiddler 捕获我的 MVC 应用程序向 ASP.NET Web API 发出的请求。这可能吗?

【问题讨论】:

    标签: asp.net asp.net-mvc asp.net-web-api fiddler


    【解决方案1】:

    Fiddler Docs 指出了这个确切的问题。

    这有两个部分

    1 在 web.config 中将 MVC 应用设置为使用 fiddler 作为代理

    <configuration>
     <system.net>
      <defaultProxy>
       <proxy bypassonlocal="false" usesystemdefault="true" />
      </defaultProxy>
     </system.net>
    </configuration>
    

    或在代码中:GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);

    2 通过机器名而不是 localhost 引用您的 api。 这是因为默认情况下,.net 在通过 localhost 引用某些内容时不会使用代理。

    【讨论】:

    • 经过几个令人沮丧的小时后,想知道为什么以前在同一个应用程序中无法正常工作 - 您必须在管理员模式下运行 Visual Studio 才能工作
    【解决方案2】:

    .NET 框架经过硬编码,不会通过代理将流量传递到 localhost。尝试使用http://localhost.fiddler:xxxx/。这应该通过提琴手路由您的请求,以便它可以捕获流量。有关更多详细信息和其他几个地址选项,请参阅 Fiddler Documentation on this problem。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-13
      • 2016-09-25
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      • 2021-12-08
      • 1970-01-01
      相关资源
      最近更新 更多