Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) returns empty string in ASP.Net project

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

like image 234
JWhitsitt Avatar asked Aug 13 '11 19:08

JWhitsitt


1 Answers

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.

like image 110
Nathan Ratcliff Avatar answered Nov 26 '22 06:11

Nathan Ratcliff