Код: Выделить всё
using MyClientApp;
public async Task MyAsyncTask()
{
try
{
await _myClient.SendServiceRequestAsync();
}
catch (Exception ex)
{
var test = ex.Message;
}
}
< /code>
_myClientКод: Выделить всё
SendServiceRequestAsync()Код: Выделить всё
private async Task SendServiceRequestAsync()
{
using HttpClient client = new();
client.BaseAddress = new Uri("http://localhost:8087");
return await client.GetAsync(_requestUri);
}
< /code>
To test exception handling, I intentionally did [b]not[/b] start the Docker service that runs on localhost:8087ex.message < /code> в блоке улова:
Ошибка произошла при отправке запроса. is:
Невозможно подключиться к удаленному серверу < /p>
< /blockquote>
< /li>
< /ul>
Однако, отладки поведение клиента. быть сделанным, потому что целевая машина активно отказалась от него. (Localhost: 8087) < /p>
< /blockquote>
Код: Выделить всё
SendServiceRequestAsync()Почему я вижу только общее сообщение, что возникла ошибка ... in ex.message , и не более конкретное, как не может быть связано с подключением ... ? отладка?
Подробнее здесь: https://stackoverflow.com/questions/797 ... ethod-call
Мобильная версия