I have a modified hosts file which is as follows:
192.168.10.10 library.test
and I try to connect to this domain from a UWP app using HttpClient like so
var client = new HttpClient();
var result = await client.GetAsync("http://library.test");
Console.WriteLine(result.StatusCode);
but this fails with the following exception
HResult=0x80072EFD
Message=An error occurred while sending the request.
Source=System.Net.Http
StackTrace:
at System.Net.Http.HttpClientHandler.<SendAsync>d__111.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at WordsmithsApp.ViewModels.LoginViewModel.<TryLogin>d__4.MoveNext() in C:\Users\dubif\mods-n-stuff\Coding\Projects\WordsmithsApp\WordsmithsApp\WordsmithsApp\ViewModels\LoginViewModel.cs:line 37
Inner Exception 1:
COMException: The text associated with this error code could not be found.
A connection with the server could not be established
This same code works fine when using a host such as https://google.com
I did not reproduce your problem, when I try to modify the website library.test
in the host and direct it to the local webpage, it can be accessed normally.
Please check the following:
Is 192.168.10.10
an accessible IP address? If you only access the local, you can change to 127.0.0.1
.
If you do not set a port number, then the default is access to port 80, please ensure that there is accessible content under this port.
User contributions licensed under CC BY-SA 3.0