C# 无法让 Fiddler 捕获到 IIS 的本地流量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16994111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 08:17:48  来源:igfitidea点击:

Can't Get Fiddler to Capture local traffic to IIS

c#asp.netiisfiddler

提问by pharophy

I have recently installed the latest Fiddler (Fiddler4) and absolutely nothing that I try is working to get it to capture local traffic. I have an MVC application that is connecting to an MVC WebApi app both running on IIS, here's what I've tried:

我最近安装了最新的 Fiddler (Fiddler4),我尝试的任何方法都无法让它捕获本地流量。我有一个 MVC 应用程序,它连接到一个都在 IIS 上运行的 MVC WebApi 应用程序,这是我尝试过的:

  • Fiddler Options > Connections > Monitor All Connections & Use PAC Script
  • Changed the WebClient C# call to use the following URLs with no success:
  • Changed my "Default Website" in IIS to run under a new AppPool that uses my local account, and ran Fiddler as administrator
  • added <system.net> <defaultProxy> <proxy bypassonlocal="False" usesystemdefault="True" /> </defaultProxy> </system.net> to my web.config of the MVC app.
  • Fiddler 选项 > 连接 > 监控所有连接并使用 PAC 脚本
  • 将 WebClient C# 调用更改为使用以下 URL,但未成功:
  • 将 IIS 中的“默认网站”更改为在使用我的本地帐户的新 AppPool 下运行,并以管理员身份运行 Fiddler
  • 添加<system.net> <defaultProxy> <proxy bypassonlocal="False" usesystemdefault="True" /> </defaultProxy> </system.net> 到我的 MVC 应用程序的 web.config。

Nothing has worked, I have no idea what to try. Any advice is greatly appreciated. Thanks, Shawn

没有任何效果,我不知道该尝试什么。任何意见是极大的赞赏。谢谢,肖恩

采纳答案by pharophy

It turned out that I needed to set up Fiddler as a reverse proxy (http://fiddler2.com/documentation/Configure-Fiddler/Tasks/UseFiddlerAsReverseProxy). I don't really understand why before I upgraded from Fiddler2 to Fiddler4 I didn't have to do this. I used to be able to just use http://ipv4.localhost/app-nameand all worked fine. In order to get it working with Fiddler4, though, I set-up the reverse proxy, and then changed all my requests from http://ipv4.localhost/app-nameto http://machinename:8888/app-name. I can now listen in to inter-app communications. Any idea why I didn't have to do this with Fiddler2, but I now do after upgrading to Fiddler4?

事实证明,我需要将 Fiddler 设置为反向代理(http://fiddler2.com/documentation/Configure-Fiddler/Tasks/UseFiddlerAsReverseProxy)。我真的不明白为什么在从 Fiddler2 升级到 Fiddler4 之前我不必这样做。我曾经能够使用http://ipv4.localhost/app-name并且一切正常。为了得到它Fiddler4的工作,不过,我设置了反向代理,然后改变了我所有的请求从http://ipv4.localhost/app-namehttp://machinename:8888/app-name。我现在可以收听应用程序间的通信。知道为什么我不必用 Fiddler2 这样做,但我现在升级到 Fiddler4 后这样做吗?

回答by Joe Enos

Try adding a record in your hosts file (c:\windows\system32\drivers\etc\hosts), like:

尝试在您的主机文件 (c:\windows\system32\drivers\etc\hosts) 中添加一条记录,例如:

127.0.0.1   mysite.local

You'll then need a binding in your website in IIS to match.

然后,您需要在 IIS 中的网站中进行绑定以进行匹配。

Then use http://mysite.local/

然后使用http://mysite.local/

回答by Alexei Levenkov

The easiest reliable solution I know to capture non-Webbrowser traffic is to explicitly specify Fiddler's port as proxy for web requests. Depending on requests your code is making code would look similar to:

我知道捕获非 Webbrowser 流量的最简单可靠的解决方案是明确指定 Fiddler 的端口作为 Web 请求的代理。根据您的代码正在制作的请求,代码看起来类似于:

 request.Proxy = new WebProxy("127.0.0.1", 8888)

Note: don't forget to run Fiddler with "Capturing" and "All Process" (visible in status bar of Fiddler)

注意:不要忘记使用“捕获”和“所有进程”运行 Fiddler(在 Fiddler 的状态栏中可见)

回答by Rahul Soni

Try using http://machinename./page

尝试使用http://machinename./page

i.e... try suffixing a period to the machine name and browse.

即.. 尝试在机器名称后缀一个句点并浏览。

回答by deadlydog

I know you mentioned this in your OP, but this worked for me and was super simple to do, so I thought I would share in case others run into the same problem and don't want to go through the trouble of setting up a reverse proxy if they don't need to.

我知道你在你的 OP 中提到了这一点,但这对我有用并且做起来非常简单,所以我想我会分享以防其他人遇到同样的问题并且不想经历设置反向的麻烦如果他们不需要代理。



I got this to work by simply changing the IIS Application Pool whose traffic I wanted to inspect to run under my identity, since Fiddler seems to only capture traffic of the logged in user by default. Just make sure your user has all of the necessary permissions required by IIS; I'm an admin so this wasn't an issue for me. And of course, don't forget to change the IIS Application Pool identity back when you are done.

我通过简单地更改我想要检查其流量的 IIS 应用程序池以我的身份运行来实现这一点,因为 Fiddler 默认情况下似乎只捕获登录用户的流量。只需确保您的用户具有 IIS 所需的所有必要权限;我是管理员,所以这对我来说不是问题。当然,完成后不要忘记更改 IIS 应用程序池标识。

The other option of course is to instead log in as the user that the IIS Application Pool is running as (if it's not a service account like Network Service) and then run Fiddler while logged in as that other user.

当然,另一种选择是以运行 IIS 应用程序池的用户身份登录(如果它不是像 那样的服务帐户Network Service),然后在以其他用户身份登录时运行 Fiddler。

回答by Chinthaka Fernando

I got the same issue. fixed by modifying Web.config

我遇到了同样的问题。通过修改Web.config修复

<system.net>
    <defaultProxy enabled="true">
        <proxy proxyaddress="http://127.0.0.1:8888" bypassonlocal="False"/>
    </defaultProxy>
</system.net>