Click here to Skip to main content
15,306,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Ladies and Gentlemen,

I am currently creating a folder and writing a file to the folder that need to be create on a file server that we have. When i do a localhost test, it work perfectly but when i access the website from outside the localhost and from another pc. It said that

System.UnauthorizedAccessException: Access to the path 'My File Server URL' 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 , 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.

But the thing is that i have already set the identity impersonate="true" in the web.config and it still didn't work. My web server is running on Winder Server 2003 and IIS 6. I tried adding the NETWORK Service and IIS_WKG to the folder for permission also can't work.

Any advice and help will be deeply appreciated

Thanks Brandon
Updated 13-Oct-11 20:42pm
Yuri Vital 14-Oct-11 4:03am
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6

Remove impersonation.

Give permission for ASPNET account !
hitech_s 14-Oct-11 5:14am
for such type of situation you should create the folder first and give permissions to that file/folder then only you can create file in that folder

1 solution

Hi Guys i manage to find the solution to it
If u are creating a folder,using this code before file or folder creation

WindowsImpersonationContext ctx = WindowsIdentity.Impersonate(IntPtr.Zero);
// Insert the create code here

Well i do not know if this is the best solution. if anyone know the downside or implication of this code please share and comment.

no harm knowing more


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900