C
c676228
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
}
}
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
}
}