I have an issue with the method Server.MapPath.
I am currently using the method HttpContext.Current.Server.MapPath("MyPath")
to obtain the physical path of "MyPath" in an ApiController, get method.
If I try to use the same method in an ApiController which returns an HttpResponse, it gives the error:
Current
is not a member ofSystem.Net.Http.HttpContent
How can I use the method Server.MapPath
in the context of an HttpResponseMessage
?
(I am working in Visual Basic)
Edit: I am using it like this:
<HttpGet>
Public Function MyFunc() As HttpResponseMessage
Try
Dim streamContent = New PushStreamContent(_
Function(outputStream, httpContext, transportContent)
Try
Dim lPath = httpContext.Current.Server.MapPath(MyPath)
.... some code
End Try
End Function)
Dim lResult = New HttpResponseMessage(HttpStatusCode.OK)
lResult.Content = streamContent
Return lResult
End Try
End Function