【问题标题】:Saving generated images on IIS virtual directory?将生成的图像保存在 IIS 虚拟目录中?
【发布时间】:2017-06-07 07:21:02
【问题描述】:

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

我创建了保存路径:

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

并返回resultPath

问题是,我保存站点的虚拟目录是C:\\sites\siteA,而HttpContext.Current.Server.MapPath("/" + resultPath) 返回C:\\inetpub\wwwroot\Images\123456.png。那我就不可能从10.0.0.106/siteA/Images/123456.png加载图片了。

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

【问题讨论】:

  • 试试这个var fullPath = HttpContext.Current.Server.MapPath("~/" + resultPath);
  • @PranavPatel 它有效。谢谢你:)
  • 很乐意为您提供帮助

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


【解决方案1】:
string resultPath = obiektId.ToString() + ".png";
string fullPath  = System.Web.HttpContext.Current.Server.MapPath("~/Images"+ resultPath );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 2018-01-12
    相关资源
    最近更新 更多