This is a migrated thread and some comments may be shown as answers.

Fiddler do not display traffic between 2 web service on .netCore

1 Answer 557 Views
Windows
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 12 Jan 2018, 02:43 PM
Step to reproHi,

I've got some problem tracing reauest between web application. I describe below how to reproduce.
Hope you can help me :)

Requirements:
windows10
Visual Studio 2017
.netcore


Step to reproduce:

- Launch a first Instance of Visual Studio, File -> New -> Project -> .Net Core -> ASP.NET Core Web Application -> OK -> Web APi -> OK.
Go into properties of Web Application, tab Debug, and get the App Url.
Example: instance 1 : http://localhost:58557/

- Launch a second instance of Visual Studio, and do the same as step 1.
Example: instance 2 : http://localhost:50214/

- In first instance, go in file Controllers -> ValuesCOntroller
Replace first method by this code :
        // GET api/values
        [HttpGet]
        public IEnumerable<string> Get()
        {
            WebProxy proxy = new WebProxy("http://127.0.0.1:8888/", false);
            HttpClientHandler handler = new HttpClientHandler()
            {
                Proxy = proxy,
                UseProxy = true,
                PreAuthenticate = true,
                UseDefaultCredentials = true,
            };
            HttpClient httpClient = new HttpClient(handler);
            //HttpClient httpClient = new HttpClient();
            var t = httpClient.GetAsync("http://localhost:50214/api/values").Result.Content.ReadAsStringAsync();
            return new string[] { "value1", "value2" };
        }

Be careful, replace http://localhost:50214 with the URL of your second instance.
This code will call second instance using proxy 127.0.0.1:8888.

- Launch Fiddler, and check that proxy is correctly enabled and set to 127.0.0.1:8888.

- Launch both instance of web application.

- Call first Web Application using IE, postman or whatever... GET http://localhost:58557/api/values

- In fiddler, you'll see one line :
1    200    HTTP    localhost:58557    /api/values    30        application/json; charset=utf-8    postman:9972    

- The call to the second web application is not visible.


        


1 Answer, 1 is accepted

Sort by
0
Vincent
Top achievements
Rank 1
answered on 23 Jan 2018, 09:51 AM

The solution is to launch solutions on IIS, and use the local machine name instead.

 

httpClient.GetAsync("http://myMachineName/WebApplicationTest/api/values").Result.Content.ReadAsStringAsync();

 

 

Tags
Windows
Asked by
Vincent
Top achievements
Rank 1
Answers by
Vincent
Top achievements
Rank 1
Share this question
or