vb.net get代码, 如果改进foxtable中, 还有post方法应该如何写?
Imports System.Net.Http
Imports System.Threading.Tasks
Public Class WebApiClient
Private Shared ReadOnly _client As New HttpClient()
Public Shared Async Function GetDataAsync(ByVal uri As String) As Task(Of String)
Try
Dim response As HttpResponseMessage = Await _client.GetAsync(uri)
If response.IsSuccessStatusCode Then
Dim content As String = Await response.Content.ReadAsStringAsync()
Return content
Else
Return Nothing
End If
Catch ex As Exception
' 处理异常
Return Nothing
End Try
End Function
End Class
改不了,这个是高版本的net 4.5及以上才有功能,Foxtable只支持到net4.0。
4.0可以看看:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=133325&replyID=889181&skin=1
https://docs.microsoft.com/zh-cn/dotnet/api/system.net.httpwebrequest?view=netframework-4.0