开发者

Using Fiddler with IIS7 Express

开发者 https://www.devze.com 2023-02-05 03:39 出处:网络
I am using IIS7 Express while developing my web application.I need to u开发者_开发技巧se fiddler to investigate an issue and cannot figure out how to configure things so I can get the HTTP stream.It s

I am using IIS7 Express while developing my web application. I need to u开发者_开发技巧se fiddler to investigate an issue and cannot figure out how to configure things so I can get the HTTP stream. It seems that IIS7 express will only listen on localhost which means I cannot access the stream.


This has nothing to do with IIS7 Express and everything to do with the fact that you're using loopback traffic.

Ref: https://www.fiddlerbook.com/fiddler/help/hookup.asp#Q-LocalTraffic

Click Rules > Customize Rules.

Update your Rules file like so:

static function OnBeforeRequest(oSession:Fiddler.Session)
{
    if (oSession.HostnameIs("MYAPP")) { oSession.host = "localhost:portnumber"; }
}

Then, just visit http://myapp in your browser.

Or use the address http://localhost.fiddler/ and Fiddler will use the hostname localhost instead of converting to an IP address.


One useful variation of Eric's answer (that was edited by Brett) would be to use oSession.port to build the oSession.host. With this little change, if one needs to capture IIS express traffic on http://localhost:12345, they could use http://iisexpress:12345. That will make it easier to capture traffic for sites with random ports as created by WebMatrix and VS. I tried it out with IE and Firefox and capturing IIS Express traffic was a breeze. Fiddler rocks!.

static function OnBeforeRequest(oSession:Fiddler.Session)
{
   //...
   // workaround the iisexpress limitation
   // URL http://iisexpress:port can be used for capturing IIS Express traffic
   if (oSession.HostnameIs("iisexpress")) { oSession.host = "localhost:"+oSession.port; }
   //...
}


With the latest version of fiddler, you only need to navigate to localhost.fiddler:port. However, doing that alone didn't help me and I was still getting access denied when using Windows Authentication. To fix this, I found this blog entry: http://www.parago.de/2013/01/fiddler-and-the-401-unauthorized-error-with-asp-net-web-api-using-integrated-windows-authentication-wia/

In short, create this key:

Key Path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Control\Lsa\MSV1_0

Value Name BackConnectionHostNames

Value Type REG_MULTI_SZ

String Value localhost.fiddler


You can use fiddler as a proxy between your clients and the server. This means you start up fiddler, and then access the server using fiddler's port rather then the usual port (default for fiddler2 is 8888 I think). If you need to debug the server "live" vs. real world clients, you can change the IIS binding from :80 to something else, and place fiddler's proxy on port 80.

EDIT: By the way, by default fiddler2 changes the proxy settings on your browsers so that they access everything through fiddler anyway (on the machine in which fiddler is installed only)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号