I am trying to to fetch image from server and display in my mobile using .net core API. and I use System.Web.Hosting.HostingEnvironment.MapPath(path) to map the path from server but it throw me an error System.Web.Hosting not include in System.Web how can fix this problem? pls help me.
And I try to add System.Web, i chage target framework from .net core 2.0.0 to .net core 2.2.0
using System.Threading.Tasks;
using BRT.API.Helpers;
using BRT.BLL.Model;
using BRT.BLL.Services;
using BRT.BLL.Services.Interfaces;
using BRT.DAL.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
//using System.Web.Hosting;
using System.Net;
using System.Net.Http;
[AllowAnonymous]
[HttpGet]
[Route ("ReadConfirmationPhoto/{productSN}")]
public async Task<HttpResponseMessage> ReadConfirmationPhoto (string productSN) {
var result = await _service.ReadPhysicalFile (productSN);
HttpRequestMessage request = new HttpRequestMessage();
var response = request.CreateResponse(HttpStatusCode.OK);
var path = result.FileName;
path = System.Web.Hosting.HostingEnvironment.MapPath(path);
var ext = System.IO.Path.GetExtension(path);
var contents = System.IO.File.ReadAllBytes(path);
System.IO.MemoryStream ms = new System.IO.MemoryStream(contents);
response.Content = new StreamContent(ms);
response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ext);
return response;
}