How to display localhost traffic in Fiddler while debugging an ASP.NET application?

后端 未结 14 1409
野的像风
野的像风 2020-12-07 13:23

How do I display localhost traffic in Fiddler while debugging an ASP.NET application?

14条回答
  •  不思量自难忘°
    2020-12-07 13:50

    Using Fiddler v4:

    1. Check your IE proxy settings

    IE->Tools->Internet Options->Connections->Lan Settings

    1. Check your settings in Fiddler:

    Fiddler -> Options-> Connections & Https

    Check the Fiddler port, default is 8888

    1. In Fiddler-Menu:

    File -> Capture Traffic is checked

    The following solution worked for me, when using a

    • HttpClient or
    • WebClient from inside an ASP.NET application.

    Web.config

    
        
          
        
    

    Code:

    var resourceServerUri = new Uri("http://localhost.fiddler:YourAppServicePort");
    var body = c.GetStringAsync(new Uri(resourceServerUri)).Result;
    



    Check if your request actually reaches fiddler by customizing the Fiddler Rules script

    Fiddler->Rules->Customize Rules

    and hook into the OnBeforeRequest event:

    static function OnBeforeRequest(oSession: Session) {
    
    if (oSession.hostname.Contains("localhost:YourPortNumber")
    {
     System.Windows.Forms.MessageBox.Show(oSession.hostname);  
    } 
    

    Or explicitly by setting a web proxy

    WebClient wc = new WebClient();
    
    WebProxy proxy = new WebProxy();
    // try one of these URIs
    proxy.Address = new Uri("http://127.0.0.1:8888");
    proxy.Address = new Uri("http://hostname:8888");
    proxy.Address = new Uri("http://localhost.fiddler");
    proxy.Address = new Uri("http://ipv4.fiddler");
    // https://en.wikipedia.org/wiki/IPv6
    proxy.Address = new Uri("http://ipv6.fiddler");
    
    proxy.BypassProxyOnLocal = false; wc.Proxy = proxy;
    var b = wc.DownloadString(new Uri(YourResourceServerBaseAddress));
    

提交回复
热议问题