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.
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.