Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 911
  • Last Modified:

Can't access file on IIS7 Windows Server 2008 R2

Dear Experts,

My asp.net c# application is hosted on IIS7 running on windows server 2008r2.
in that application i access a file on the server, however, i am getting the following error:
Access to the path 'filename' is denied.

i know i am supposed grant asp.net user on the server access to the folder/file by right-clicking & going to security

but the thing is, when i go to do that, i don't see any asp.net user at all!

can you please guide me about giving permissions so that i can access the file from my web application?
0
RakeshBhandari
Asked:
RakeshBhandari
  • 6
  • 4
1 Solution
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi, probably your ASPNET application pool is using the identity "ApplicationPoolIdentity"

You need to grant access to:
IIS AppPool\DefaultAppPool

Open in new window

over the files/folders in the security tab (add this account manually if not appears in the object list).

Also you can try change your ASPNET application pool identity by selecting it from the IIS console and changing its advanced settings, then set the identity to NETWORKSERVICE and grant access to this account over your files.

More info about IIS7 application pool identities on Windows Server 2008 R2:
http://learn.iis.net/page.aspx/624/application-pool-identities/
0
 
RakeshBhandariAuthor Commented:
i tried this already and hasn't worked for me

is there anything else i can do... or is there a workaround?
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi, I need more info to be able to give you a solution to your problem.

Please copy this aspx page into your web application folder where is your page that is trying to access the file, then open it from your web browser and post here the displayed info:
Im.aspx

The page just display user authentication info and the windows identity info that is running your page, that will give me enough info to know what action to take.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
RakeshBhandariAuthor Commented:
here's the info :

User

AuthenticationType:
Name:
IsAuthenticated: False
WindowsIdentity

Name: IIS APPPOOL\DefaultAppPool
AuthenticationType: Negotiate
ImpersonationLevel: None
IsAnonymous: False
IsAuthenticated: True
IsGuest: False
IsSystem: False
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi buddy! That is your answer, open the security tab of your folder and grant access to:
IIS APPPOOL\DefaultAppPool

Open in new window

Just copy and paste this account name instead of find it in the object list, you know what I meant?
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Can you do this?

1. Open your folder properties, then go to the security tab, click Edit, click Add:
Step 12. Select the user, set the permissions, and click OK:
Step 2
Try write the file again from your web application.
0
 
RakeshBhandariAuthor Commented:
i did that already and still i am getting the same error!
0
 
RakeshBhandariAuthor Commented:
well... i rebooted the machine (without making any more changes apart from the one in your screenies) and voila! it works!!

thank you very much!!!
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Good! Hehe that this happens in the Windows World ;)
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
I meant: that THINGS happens in the Windows World ;)
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now