반응형
1.
private string HttpGet(string url)
{
System.Net.WebClient Client = new System.Net.WebClient();
try
{
return Client.DownloadString(url);
}
catch
{
return "";
}
}
2.
public System.Threading.Tasks.Task<string> HttpGet(string url)
{
System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient();
try
{
return Client.GetStringAsync(url);
}
catch
{
return System.Threading.Tasks.Task.FromResult(string.Empty);
}
}
반응형
'C#' 카테고리의 다른 글
[C#] decimal Parse 지수 값을 허용하고 규칙에 따라 문자열 처리 (0) | 2022.09.20 |
---|---|
[C#] HttpPost 2가지 방법 (0) | 2022.08.26 |
[C#] Decimal Min Max (0) | 2022.08.25 |
[C#] ByteArrayToHexString (0) | 2022.08.25 |
[C#] Random Decimal (0) | 2022.08.25 |
댓글