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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gwkleinAuthor Commented:
Here is the Blog post from Rick Strahl - http://www.west-wind.com/WebLog/posts/2153.aspx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.