The second argument passed to your callback function is of type HttpContent
. You're effectively hiding HttpContext
inside your lambda because you're named that parameter HttpContext
. Try:
Dim streamContent = New PushStreamContent(_
Function(outputStream, content, transportContent) 'Renamed parameter here
Try
Dim lPath = HttpContext.Current.Server.MapPath(MyPath)
'.... some code
Catch ex As Exception
Finally
outputStream.Close()
End Try
End Function)
The PushStreamContent
constructor definition is:
Public Sub New ( _
onStreamAvailable As Action(Of Stream, HttpContent, TransportContext) _
)