I have a VB.NET function as below:
Public Shared Async Function GetIdDoc() As Task(Of String)
Dim result As String = ""
'Dim Uri As String = "http://localhost:53917/api/Documenti/GetNextIdDocumenti"
Dim Uri As String = apiUri & ApiEndPoints.GetNextIdDocumenti
Using client = New HttpClient()
Using response = Await client.GetAsync(Uri)
If response.IsSuccessStatusCode Then
Dim DocumentiIDJsonString = Await response.Content.ReadAsStringAsync()
result = DocumentiIDJsonString.ToString()
End If
End Using
End Using
Return result
End Function
I'm trying to return the Document ID from the DB but I'm getting
System.Threading.Tasks.Task`1[System.String]
Where actually it should return "2". Please help me on this: what am I doing wrong with this function?
Update
here is the function called:
txtIDDoc_Detail.Text = ApiData.GetIdDoc().ToString()
But inside the textbox I'm getting the above text. thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…