DARK__FOXX
Member
- Joined
- Sep 2, 2020
- Messages
- 16
- Programming Experience
- Beginner
Hi,
I found this function to create a request POST that visualize json data in an ASP:NET project, I would like to find a way to make async, but i don't know how to do.
I know that i need to use these method:
BeginGetRequestStream / EndGetRequestStream
BeginGetResponse / EndGetResponse
but I don't know where to use and If i need to use Task
I found this function to create a request POST that visualize json data in an ASP:NET project, I would like to find a way to make async, but i don't know how to do.
VB.NET:
Private Function SendRequestPOST(uri As Uri, jsonDataBytes As Byte(), contentType As String, method As String, token As String) As String
Dim response As String
Dim request As HttpWebRequest
request = WebRequest.Create(uri)
request.PreAuthenticate = True
request.Headers.Add("Authorization", "Bearer " + token)
request.Accept = contentType
request.Method = method
Using requestStream = request.GetRequestStream
requestStream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
requestStream.Close()
Using responseStream = request.GetResponse.GetResponseStream
Using reader As New StreamReader(responseStream)
response = reader.ReadToEnd()
End Using
End Using
End Using
Return response
End Function
I know that i need to use these method:
BeginGetRequestStream / EndGetRequestStream
BeginGetResponse / EndGetResponse
but I don't know where to use and If i need to use Task
Last edited by a moderator: