IIS Express Access denied

2019-02-15 11:54发布

I am trying to create new file in visual studio 2012

fileStream = new FileStream("google_com.txt", FileMode.CreateNew);

But i keep getting this error Access to the path 'C:\Program Files (x86)\IIS Express\google_com.txt' is denied.

Plz help to fix this poblem.

5条回答
霸刀☆藐视天下
2楼-- · 2019-02-15 12:22

Solutions:

  1. Put a specific location for google_com.txt file. like C:\google_com.txt. Actually it is not allowing to create the file in default location(inside program files) as it might not have the proper privilege.
  2. If you want to create the file in default location(inside program files) run Visual Studio as Administrator.(R-Click-> Run as Administrator).
查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-02-15 12:22

Official Microsoft response:

Issue occurs because of missing permissions on a local resource that the ASP.NET application tries to access If you are unable to get a clear description of the problem because of a custom error message, run FileMon and reproduce the problem. Stop and save the capture as FileMon.xls and open the file in Microsoft Excel. On the Data menu, click Filter, and then click AutoFilter to use the filtering capabilities of Excel. Now select the drop-down list in column F and look for "ACCESS DENIED" errors.

A sample FileMon output is shown below. 10381 1:01:11 PM w3wp.exe:2320 OPEN C:\winnt\microsoft.net\framework\v1.1.4322\Temporary ASP.NET Files\sessiontest\8832e585\275ec327\global.asax.xml ACCESS DENIED NT AUTHORITY\NETWORK SERVICE As you can see from the filtered results, we have narrowed down the cause of the problem. FileMon shows that the NT AUTHORITY\NETWORK SERVICE account is missing NTFS permissions on the C:\Winnt\Microsoft.net\Framework\v1.1.4322\Temporary ASP.NET Files folder. This should be straight forward to fix. For more information about using FileMon to troubleshoot ASP.NET, click the following article number to view the article in the Microsoft Knowledge Base

https://support.microsoft.com/es-ve/help/910449/troubleshooting-common-permissions-and-security-related-issues-in-asp

查看更多
在下西门庆
4楼-- · 2019-02-15 12:28

Run Visual Studio as Administrator

查看更多
聊天终结者
5楼-- · 2019-02-15 12:31

You can't write to the Program Files folders on Windows Vista or later unless you're running elevated/as an administrator.

You should be writing to the application's App_Data folder if you need to write anywhere. Look into using Server.MapPath().

查看更多
聊天终结者
6楼-- · 2019-02-15 12:42

If this is in a web app, the file will be created in the application's root, which in this case is your iis express directory. Run Visual Studio as Administrator, or change the location of the file by specifying an explicit path.

查看更多
登录 后发表回答