I need to create web API that generate some images and return their paths.
I create the path to save using:
var resultPath = "Images/" + obiektId.ToString() + ".png";
var fullPath = HttpContext.Current.Server.MapPath("/" + resultPath);
and return resultPath
.
The problem is, that the virtual directory where I keep my site is C:\\sites\siteA
and HttpContext.Current.Server.MapPath("/" + resultPath)
returns C:\\inetpub\wwwroot\Images\123456.png
. Then it is impossible for me to load the image from 10.0.0.106/siteA/Images/123456.png
.
How can I save my image in my base virtual directory instead of saving it in wwwroot directory?
string resultPath = obiektId.ToString() + ".png";
string fullPath = System.Web.HttpContext.Current.Server.MapPath("~/Images"+ resultPath );