• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1588
  • Last Modified:

A generic error occurred in GDI+ - permissions

When I attempt to save an image file to a virtual directory I get "A generic error occurred in GDI+." This seems to be a permission issue, because during the debug process, I changed the file path to my local hard drive and was able to save the file.

The virtual directory is running under a specific domain account, with full control given to the folder and the share.

IIS is serving the images, and I can navigate through the directory structure of the virtual directory in IIS, and also save, rename and delete files in the folder while connected as the domain account.

When I attempt to save the file from the application, does IIS connect as some other user, other than me or the domain account?

Any help with this would be appreciated!

int iImagePercentage = (CROPPED_IMAGE_WIDTH * 100) / this.View.FullSizeImage.Width;
                    int iThumbnailPercentage = (CROPPED_THUMBNAIL_WIDTH * 100) / this.View.FullSizeImage.Width;
                       using (System.Drawing.Image articleImage = ImageProcessor.ScaleByPercent(this.View.FullSizeImage, iImagePercentage))
                        newArticle.ImagePath = System.IO.Path.Combine(this.View.ImageHttpPath, this.View.ImageUploadFilename);
                        articleImage.Save(this.View.ImageUploadPath, System.Drawing.Imaging.ImageFormat.Jpeg);

Open in new window

  • 2
1 Solution
Miguel OzSoftware EngineerCommented:
Make sure the following account have write permissions to your target folder:
Internet Guest Account (MYSERVER\IUSER_MYSERVER)

I have fixed this issue for me by right clicking folder and adding \everyone.  with full control.
gwkleinAuthor Commented:
Adding everyone did not work, but after some Googling we found a blog post by Rick Strahl which fixed the problem.  To determine the account that the application in running under we used <%= Environment.UserName %> - this returned ASPNET (IIS 5.1 - does not have appPools)

We then added a username and password to the machine.config so the app would run under an account that we specified and not the ASPNET account


Hope this helps someone!
gwkleinAuthor Commented:
Here is the Blog post from Rick Strahl - http://www.west-wind.com/WebLog/posts/2153.aspx

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now