【问题标题】:A generic error occurred in GDI+ savingGDI+ 保存时发生一般错误
【发布时间】:2019-01-02 18:06:03
【问题描述】:

我正在尝试将文件从一台服务器保存到另一台服务器。用户将上传一个 jpeg 文件到服务器。在我的控制器中,我使用“HttpPostedFileBase”获取文件数据。如果我想在本地服务器上上传这个文件,它没有问题(基于Web的管理应用程序IP是xxx.xxx.xxx)。但是,如果我想将数据上传到另一台服务器(IP 是 yyy.yyy.yyy),我会收到标题上显示的这个错误。

我也在做模拟以到达感兴趣的文件夹。该文件夹在 (yyy.yyy.yyy) 机器上具有 IIS_USER、NetworkService、Everyone 用户的完全管理员权限。

我也尝试使用文件复制来执行此代码,移动到 exe 文件中,但我没有收到任何错误。所以这段代码只在 ASP.Net MVC 应用程序中给出错误。

您可以查看下面的部分代码:

if (isImpersonated)
        {

            //File.ResizeImage(1000, 1000).Save(Server.MapPath(Path.Combine(WebConfigurationManager.AppSettings["PicturePath"], fileName)));
            //File.ResizeImage(500, 500).Save(Server.MapPath(Path.Combine(WebConfigurationManager.AppSettings["MarinaPicturePath"], string.Format("{0}-medium{1}", imgName, Path.GetExtension(File.FileName)))));
            //File.ResizeImage(250, 250).Save(Server.MapPath(Path.Combine(WebConfigurationManager.AppSettings["MarinaPicturePath"], string.Format("{0}-small{1}", imgName, Path.GetExtension(File.FileName)))));

            //File.Copy("C:\\test\\asd.txt", "\\\\31.123.1.123\\C$\\test\\asd123.txt");
            //System.IO.File.Copy("C:\\test\\asd.txt", "\\\\31.123.1.123\\C$\\test\\asd123.txt");   


            //File.ResizeImage(1600, 1200).Save(Server.MapPath(Path.Combine(WebConfigurationManager.AppSettings["PicturePath"], fileName)));

            File.ResizeImage(1000, 1000).Save(Path.Combine("\\\\31.123.1.123\\C$\\test\\", fileName));
            File.ResizeImage(500, 500).Save(Server.MapPath(Path.Combine("\\\\31.123.1.123\\C$\\test\\", string.Format("{0}-medium{1}", imgName, Path.GetExtension(File.FileName)))));
            File.ResizeImage(250, 250).Save(Server.MapPath(Path.Combine("\\\\31.123.1.123\\C$\\test\\", string.Format("{0}-small{1}", imgName, Path.GetExtension(File.FileName)))));

            GC.Collect();
            //var asd = StreamToByteArray(File.InputStream);
            //System.IO.File.WriteAllBytes(Path.Combine("\\\\31.123.1.123\\C$\\test\\", fileName), asd);

        }

【问题讨论】:

    标签: c# asp.net asp.net-mvc file impersonation


    【解决方案1】:

    我找到了答案!如果有人会得到这个错误,应该检查 Impersination 类并设置 const int LOGON32_LOGON_INTERACTIVE = 9

    【讨论】:

      猜你喜欢
      • 2010-12-12
      • 2013-09-26
      • 1970-01-01
      • 2015-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多