当Fiddler碰上localhost
2008-06-01 21:35 晓风残月 阅读(3035) 评论(2) 编辑 收藏 举报很久没有用fiddler了(确确说应该是很久没有研究Web开发了),忽然发现fiddler竟然没有捕捉到localhost的请求,一 google
原来:
http://www.fiddlertool.com/Fiddler/help/hookup.asp#Q-LocalTraffic
Why don't I see IE7 or System.NET traffic sent to http://localhost or http://127.0.0.1?
IE7 and the .NET Framework are hardcoded not to send requests for Localhost through any proxies, and as a proxy, Fiddler cannot intercept such traffic.
The workaround is to use your machine name as the hostname instead of Localhost or 127.0.0.1. So, for instance, rather than hitting http://localhost:8081/mytestpage.aspx, instead visit http://machinename:8081/mytestpage.aspx. Alternatively, you can use http://localhost.:8081/mytestpage.aspx (note the trailing dot after localhost).
...Or, you could Customize your Rules file like so:
static function OnBeforeRequest(oSession:Fiddler.Session){
if (oSession.HostnameIs("MYAPP")) { oSession.host = "127.0.0.1:8081"; }
}...and then just hit http://myapp, which will act as an alias for 127.0.0.1:8081.
IE7 以及 System.Net 对localhost/127.0.0.1的请求不会通过任何代理发送,fiddler也就无法截获。
解决方案
- 用 http://localhost. (locahost紧跟一个点号)
- 用 http://127.0.0.1. (127.0.0.1紧跟一个点号)
- 用 http://machinename (机器名)
- 手动自定义请求规则