メソッド Server.MapPath に問題があります。
現在、メソッドを使用してHttpContext.Current.Server.MapPath("MyPath")
、ApiController で「MyPath」の物理パスを取得し、メソッドを取得しています。
HttpResponse を返す ApiController で同じメソッドを使用しようとすると、エラーが発生します。
Current
のメンバーではありませんSystem.Net.Http.HttpContent
Server.MapPath
のコンテキストでメソッドを使用するにはどうすればよいHttpResponseMessage
ですか?
(私はVisual Basicで作業しています)
編集:私はこのように使用しています:
<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