Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test locally using System.Net.Http.HttpClient in C# #7312

Closed
bdcoder2 opened this issue Apr 17, 2018 — with docs.microsoft.com · 3 comments
Closed

How to test locally using System.Net.Http.HttpClient in C# #7312

bdcoder2 opened this issue Apr 17, 2018 — with docs.microsoft.com · 3 comments

Comments

Copy link

When testing locally using a project that issues HTTP POST requests from a program created in Visual Studio, ie: using System.Net.Http.HttpClient, HttpClient always returns:

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:7170

I can make POST requests using PostMan or GET requests using a browser, but when trying to test functions locally using System.Net.Http.HttpClient calls from within Visual Studio -- it seems impossible, due to the error above.

I also tried to set the following within Web.Config (suggested in a StackOverFlow post):
<system.net>

</system.net>

No effect !

HOW can I test functions locally from programs running within Visual Studio -- specifically, when using System.Net.Http.HttpClient -- please provide an example.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@mimckitt
Copy link
Contributor

@bdcoder2 Thanks for the feedback! We are currently investigating and will update you shortly.

@bdcoder2
Copy link
Author

Oh good grief – my sincerest apologies!

I had http://localhost:7170/ as the base URL in a config file rather than (the correct) http://localhost:7071/

Two hours looking at the exception and I didn’t clue in – time for a holiday!

Once again – sorry for the false alarm and thanks for the quick reply !!

@mimckitt
Copy link
Contributor

@bdcoder2 thanks for the update and glad to hear you figured it out. And no worries, it happens to the best of us :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants