views:

122

answers:

3

I am running windows vista business 64 bit. I have a web service that was written in .NET using C#. I also have a client-side script on a web page that communicates with the web service. This is a aspx page titled "Default.aspx". I setup IIS and moved my web service folder containing the web service and all of the files that are needed to run it including the default.aspx page into C:\inetpub\wwwroot. I opened IIS manager and configured everything properly. http://localhost/mysite/Default.aspx works fine. The page loads. But I now get an error message when trying to upload an image. (There is an image uploader on the Default.aspx page) The purpose is to upload and crop the image before submitting it to the web service:

Btw, this whole thing was tested and worked on another computer so I'm not thinking there is a bug in the code although there may be but I'm thinking there's another issue. Since I'm a bit of a newbie, I'd appreciate soo much an answer with instructions to the solution

A generic error occurred in GDI+. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ExternalException (0x80004005): A generic error occurred in GDI+.] System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +377630 System.Drawing.Image.Save(String filename, ImageFormat format) +69 FaceRecognition._Default.previewBtn_Click(Object sender, EventArgs e) in D:\Project Details\Layne Projects\DotNet Project\FaceRecognition\FaceRecognition\Default.aspx.cs:114 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

A: 

I've got this error before and it was due to lack of rights on the target folder. Does ASPNET have rights to write to the folder you are specifying?

Otávio Décio
I'm not sure, how could I find out?
brandon
One way is to use sysinternal's filemon. Or simply find out the path you are using (or log it somehow), go to the folder at the IIS box and see what rights you have.
Otávio Décio
A: 

Checks the write permission on the folder where you want to save the file. The rights must be assigned to the NETWORK SERVICE user.

Fabio
A: 

Without any code posted, it's really difficult to tell.

However, given that it is an ASP.NET environment, and it "works on your machine" (or at least, that is the implication), my first impression would be to see if the user that the ASP.NET process is running under has perimissions to write to the directory that you are trying to save the image to.

If that is indeed the case, you should assign write permissions to the user that the web application is running under.

However, do not assign it to one of the users associated with the IIS process or the ASP.NET process. These are special accounts and you generally shouldn't assign extra permissions to them.

Rather, create a standard user and have your web app run under that identity (easy enough to do through web.config) and then give that user the rights to write to the directory that you are saving the image do.

If you are impersonating the user that is logged in, then you have to make sure that every user that is trying to save an image has rights to the directory where you are saving. This is best accomplished by putting all of those users in a group and then assigning the permissions and users to that particular group.

casperOne