简体   繁体   中英

IIS Express Access denied

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.

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).

管理员身份运行 Visual Studio

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().

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.

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

尝试这个:

Server.MapPath("~/ FolderName / google_com.txt ")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM