Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IIS可以';无法从UNC路径或虚拟目录加载映像_C#_Asp.net_Iis 7.5 - Fatal编程技术网

C# IIS可以';无法从UNC路径或虚拟目录加载映像

C# IIS可以';无法从UNC路径或虚拟目录加载映像,c#,asp.net,iis-7.5,C#,Asp.net,Iis 7.5,我刚刚用IIS管理器在本地安装了一个网站。我可以通过路径http://192.168.154.2/Default.aspx我有一个名为Affiche的文件夹,其中包含一些图像,位于同一网络的远程服务器中 要访问图像,我使用的是一个aspx页面GetImage.aspx,其工作方式如下: var path = "//192.168.84.52/Distri/Affiche/10038P.jpg" if ((string.IsNullOrEmpty(imageName

我刚刚用IIS管理器在本地安装了一个网站。我可以通过路径
http://192.168.154.2/Default.aspx
我有一个名为Affiche的文件夹,其中包含一些图像,位于同一网络的远程服务器中

要访问图像,我使用的是一个aspx页面GetImage.aspx,其工作方式如下:

 var path = "//192.168.84.52/Distri/Affiche/10038P.jpg"

    if ((string.IsNullOrEmpty(imageName) == false))
    {

        try
        {
            // Retrieving the image
            System.Drawing.Image fullSizeImg;
            fullSizeImg = System.Drawing.Image.FromFile(path);
            // Writing the image directly to the output stream
            fullSizeImg.Save(Response.OutputStream, ImageFormat.Jpeg);
            // Cleaning up the image
            fullSizeImg.Dispose();
        }

        catch (System.IO.FileNotFoundException)
        {
            //MessageBox.Show("There was an error opening the bitmap." +
            //    "Please check the path.");
        }
    }
此解决方案在localhost(使用Visual Studio)中运行良好,我可以通过以下链接完美地获得图像
http://localhost:3606/GetImage.aspx
,但是
http://192.168.154.2/GetImage.aspx
不起作用。它将只显示一个损坏的图像图标

可以从我安装web服务器的计算机(已经输入登录名)访问远程服务器

我使用此解决方案尝试了另一种解决方案:

从IIS管理器中,我可以完美地查看远程服务器上的文件,但当我尝试像这样访问虚拟文件夹时:
http://192.168.154.2/afficheImage/20772G.jpg

我有一个500.19错误,权限不足


有办法解决这个问题吗?

代码的第一行:

var path = "//192.168.84.52/Distri/Affiche/10038P.jpg"

这指向的IP地址与具有虚拟目录的网站不同。"192.168.154.2". 您正在从其他服务器访问图像吗?在这种情况下,您还需要检查另一台服务器上的权限。

使用下面的代码行作为路径

var path=@“\\192.168.84.52\Distri\Affiche\10038P.jpg”


这是正确的表示法,但您的斜杠无效。

请授予包含图像的文件夹“IIS\U WPG”的权限,然后重试。有关同一内容的更多详细信息,请参阅,谢谢您的回答,不幸的是,当我尝试添加它时,它告诉我无法找到IIS_WPG。我试图将其添加到本地文件夹,其中有站点文件(default.aspx,…),并从远程服务器添加到文件夹
Affiche
,但问题相同。但我确实将IIS_IUSR添加到了站点文件夹。是的,我正在从另一台服务器访问图像,我承载网站的计算机确实可以访问包含图像的服务器。我是否还需要向映像的服务器添加其他权限?当您尝试直接访问映像时,会收到什么消息?尝试从您的浏览器访问并检查其是否工作。我将显示一个找不到的404错误文件,但如果我这样做\\192.168.84.52\Distri\Affiche\10038P.jpg,它将工作。请授予“所有人”对图像文件夹的权限,然后重试。感谢您的回复,不幸的是,我无法再测试它。