【问题标题】:images not showing after website deployed to IIS网站部署到 IIS 后不显示图像
【发布时间】:2016-04-11 17:00:40
【问题描述】:

我的视图中有 img 标签,如下所示

    <img src="@Url.Action("Images", "MemberImage", new { image = TempData["id"]+".jpg" }) " 
alt=" " style="width: 100px;height:150px" />

我的控制器是

public ActionResult Images(string image)
        {
            var root = @"\\server1\PHOTOGRAPHS received\photos";
            var path = Path.Combine(root, image);
            path = Path.GetFullPath(path);
            if (!path.StartsWith(root))
            {
                // Ensure that we are serving file only inside the root folder
                // and block requests outside like "../web.config"
                throw new HttpException(403, "Forbidden");
            }

            return File(path, "image/jpeg");
        }

这在我的本地系统中运行良好,但是当我部署到 IIS 时,图片没有显示。 安装 IIS 的服务器可以访问此路径 我还需要做其他配置吗?

【问题讨论】:

  • 当您浏览到图像时,您会得到什么状态码,404、500 或其他?网站上的其他页面是否正常工作(例如纯 HTML 页面)
  • @NikolaiDante 页面正在加载其他详细信息。需要加载图像的区域是小矩形。当我检查元素时,它显示src="Client/MemberImage/Images/12345.jpg" 并给出消息图像无法加载。
  • 如果您导航到 www.yoursite.com/Client/MemberImage/Images/12345.jpg 会发生什么?客户端是 IIS 服务器上的虚拟目录吗?

标签: asp.net-mvc iis iis-7


【解决方案1】:

服务器可能有权访问共享目录,但值得检查运行网站的帐户(应用程序池使用的帐户)是否有权访问共享。

【讨论】:

  • 网站也使用相同的用户 'admin' 运行
猜你喜欢
  • 2015-10-09
  • 2018-09-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-27
  • 1970-01-01
相关资源
最近更新 更多