在IIS虚拟目录上保存生成的图像?

时间:2017-06-07 07:21:03

标签: c# asp.net asp.net-web-api iis-7 virtual-directory

我需要创建生成一些图像并返回其路径的Web API。

我创建了使用以下方式保存的路径:

var resultPath = "Images/" + obiektId.ToString() + ".png";
var fullPath = HttpContext.Current.Server.MapPath("/" + resultPath);

并返回resultPath

问题是,我保留网站的虚拟目录是C:\\sites\siteAHttpContext.Current.Server.MapPath("/" + resultPath)会返回C:\\inetpub\wwwroot\Images\123456.png。然后我无法从10.0.0.106/siteA/Images/123456.png加载图像。

如何将我的图像保存在基本虚拟目录中,而不是将其保存在wwwroot目录中?

1 个答案:

答案 0 :(得分:0)

string resultPath = obiektId.ToString() + ".png";
string fullPath  = System.Web.HttpContext.Current.Server.MapPath("~/Images"+ resultPath );
相关问题