5

I am developing ASP.Net project (framework 2.0) on local machine (Windows 7). IIS 7.5 is the local webserver.

When I run the project locally Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) returns empty string.

I am a bit sheepish and frustrated since I encountered this issue when I setup this new dev machine, but cannot remember the solution and cannot find solution by Googling. Others on the dev team running XP do not encounter this problem.

I am expecting a return of C:\Users\DefaultAppPool\AppData\Local\Microsoft\Windows\Temporary Internet Files.

Not sure if this a iis setting issue or can I set the environment variable somewhere.

Thanks, Jeff

Oded
  • 489,969
  • 99
  • 883
  • 1,009
JWhitsitt
  • 53
  • 1
  • 3

1 Answers1

6

I'm 99% sure this is going to come down to a permissions issue. In IIS7, there is a new "user" called AppPoolIdentity that is the default identity for an app pool. This user has much lower permissions than the defaults in IIS 6.

I can reproduce your issue, I have to set my AppPool to run as either LocalSystem or a specific user with administrative rights to retrieve Environment.SpecialFolder.InternetCache which makes sense when I look at the folder in question and view it's permissions.

Be aware, there are security issues with running IIS app pools with higher permissions.

Nathan Ratcliff
  • 1,392
  • 12
  • 15
  • 1
    Thanks for the response. It was helpful. I also discovered I can get a folder path by setting AppPoolIdentity to LocalSystem. – JWhitsitt Aug 13 '11 at 19:45
  • If I give DefaultAppPool, full permissions to the C:\Users\DefaultAppPool\AppData\Local\Microsoft\Windows\Temporary Internet Files folder, Environment.SpecialFolder.InternetCache still returns empty? – JWhitsitt Aug 13 '11 at 19:47
  • It's probably a combination of that folder and the folders higher up the chain. I'd be careful with relying on changing folder permissions, on my laptop (windows 7 as well), my InternetCache folder is C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files – Nathan Ratcliff Aug 13 '11 at 19:52