0

Can anybody please point me to the right direction. I am not a .NET developer and it is frustrating to find out things in .NET are not straight forward. This is a web application. In my googling I find people say this works in a console app but not in a web app:

    <WebMethod()>
    Public Async Function Send1() As Threading.Tasks.Task(Of Boolean)
        Dim client As HttpClient = New HttpClient()
        ' where url and data are predeclared
        Dim response As HttpResponseMessage = Await client.PostAsync(url,data)
        Console.WriteLine("This line never executes")
        Return True
    End Function

Tried a lot of stuff I found when googled. Like adding .ConfigureAwait(false), a lot of references pointing to an Stephen spending pages to explain it is deadlock issue, duh, yes it probably is, but what I am looking for is what would the right code be. Thank you.

King David
  • 13
  • 2
  • Does this answer your question? [Async call with await in HttpClient never returns](https://stackoverflow.com/questions/9895048/async-call-with-await-in-httpclient-never-returns) – Ricardo Souza Dec 03 '22 at 00:13
  • It doesn't. Sorry. If I add .ConfigureAwait(continueOnCapturedContext:false) it says "continueOnCaptureContext not declared" I also must use PostAsync as I am making a POST request. The call request is successful but I need to receive the response. It probably has a lot to do with where I am executing the code, it is a .asmx file receiving messages from the client browser, will that make a difference? – King David Dec 03 '22 at 00:28
  • ASMX doesn't support `async`/`await` directly. [This](https://stackoverflow.com/questions/18622372/is-there-some-way-to-handle-async-await-behind-an-asmx-service) may help. – Stephen Cleary Dec 05 '22 at 15:11

0 Answers0