Fiddler unable to crawl web project http request solution

Original link: http://www.cnblogs.com/townsend/p/9099865.html

Question: webform project docking API request using Fiddler unable to obtain the API, the older a webform project,

The same API to write to the console can grab the request, on the local IIS with the web project is not, use IIS Express can also be crawled.

Check the information to find a solution: set up a web project default local agent for listening Fiddler proxy IP.

The reason:

1. Use IE8 or earlier

2. using .net framework 4.5 or below.

Both situations are to send the request through the local proxy, all local requests can not crawl, use Fiddler default listening port of Proxy Fiddler so you can be identified.

 

1.Fiddler->Tools->Options->Connections

Fiddler find the listening port, default is 8888

 

2. Add the port's default proxy configuration node in the configuration file web.config configuration web project (recommended, put Debug configuration file does not affect the project)

  <system.net>
    <defaultProxy>
      <proxy  proxyaddress="http://127.0.0.1:8888" />
    </defaultProxy>
  </system.net>

Or in the code plus the local Fiddler proxy IP (not recommended, you can only test)

        private void Test()
        {
            ProxyObject the WebProxy = new new the WebProxy ( " 127.0.0.1 " , 8888 ); // Port is the port number integer 
            var httpClientHandler = new new HttpClientHandler
            {
                Proxy = proxyObject,
                UseProxy = true
            };
            HttpClient client = new HttpClient(httpClientHandler);
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json")
            );
            var apiUrl = "https://www.baidu.com";
            client.BaseAddress = new Uri(apiUrl);
            HttpResponseMessage response = client.GetAsync("").Result;
            var responseStr = response.Content.ReadAsStringAsync().Result;
        }

 

 

References:

IIS proxy settings: http: //fiddlerbook.com/fiddler/help/hookup.asp#Q-IIS

Fiddler proxy settings: http: //fiddlerbook.com/fiddler/help/hookup.asp#Q-LocalTraffic

IIS settings to configure the proxy IP: https: //www.cnblogs.com/fengmk2/archive/2008/04/01/1131389.html

IIS permissions: https: //markhneedham.com/blog/2009/06/24/using-fiddler-with-iis/

Reproduced in: https: //www.cnblogs.com/townsend/p/9099865.html

Guess you like

Origin blog.csdn.net/weixin_30376323/article/details/94785509