RE: Access to the path 'c:\Content\Images\Logos\34.jpg' is denied'

Hi all,

The interesting part is this user can upload logo in the CMS system for
other web sites(Same userid and password), but not specifically for this
site. That means code for uploading file in the system is the same, but not
the same site.
Does that mean the sites are configured differently?


"c676228" wrote:

Hi all,

I have the following code:

When an user upload a logo from Content Management System(which needs an
userid and password to login to upload files, but this user has an admin
permission of the server).
He got the following error message:

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.UnauthorizedAccessException: Access to the path
'c:\Content\Images\Logos\34.jpg' is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user (typically
IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose
"Properties" and select the Security tab. Click "Add" to add the appropriate
user or group. Highlight the ASP.NET account, and check the boxes for the
desired access.

Line 471: //byte[] data = new byte[fileLength];

Line 472: //f.InputStream.Read(data, 0, fileLength);

Line 473: f.SaveAs(Server.MapPath("~/Content/Images/Logos/" +
UserState.CmsSalesStorage.Data.Client.ClientID + ".jpg"));

Line 474: }

Line 475:

Source File: c:\Cms\Sales\ClientSetup.aspx.cs Line: 473
But I don't get it since this is not an anonymous user case. Is it because
of file permission we didn't set in the code?

The line 473 code I presented as follow:

void SaveLogo()
if (fileUpload.HasFile)
HttpPostedFile f = fileUpload.PostedFile;
//int fileLength = f.ContentLength;
//byte[] data = new byte[fileLength];
//f.InputStream.Read(data, 0, fileLength);
f.SaveAs(Server.MapPath("~/Content/Images/Logos/" +
UserState.CmsSalesStorage.Data.Client.ClientID + ".jpg")); //this is line 473


Relevant Pages

  • Solution design
    ... allow the end user to upload photos to the server. ... The first request would trigger for creating: ... and uses the advantages of the .NET technologies even on client side). ... we tried to create a Java applet that was trying to ...
  • Re: Problem using cURL with a web service
    ... I did try to use PUT with a web service that requires it. ... The PUT request is used to upload resources to the server. ... set the _method to put in the header, I can do this as a POST. ...
  • Re: Problem using cURL with a web service
    ... Some web services need a ... The PUT request is used to upload resources to the server. ... So they're using PUT contrary to the design of the request. ...
  • Re: Problem using cURL with a web service
    ... I did try to use PUT with a web service that requires it. ... have some resource to upload. ... much more appropriate request for their requirements. ... since _method is not part of the standard headers. ...
  • Re: I cant get httpWorkerRequest.ReadEntityBody() to work !!!
    ... ASP.NET Httpmodule to intercept file upload requests. ... The HttpWorkerRequest class is a raw abstract class ... help us access the uploaded file streams in the Multi-Part form request. ...