以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- vb.net 访问webapi接口,如何改进foxtable中 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=193376) |
-- 作者:252476276 -- 发布时间:2024/9/9 9:25:00 -- vb.net 访问webapi接口,如何改进foxtable中 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
|
-- 作者:有点蓝 -- 发布时间:2024/9/9 9:54:00 -- 改不了,这个是高版本的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
|
-- 作者:252476276 -- 发布时间:2024/9/9 10:08:00 -- 谢谢 |