30

I am trying to load existing c# web applications and getting below errors while loading any web project:

Creation of the virtual directory http://localhost:/ failed with the error: You do not have permission to access the IIS configuration file. Opening and creating web sites on IIS requires running Visual Studio under an Administrator account.. You will need to manually create this virtual directory in IIS before you can open this project.

The following error occurred when trying to configure IIS Express for project xxx.WebApi. You do not have permission to access the IIS configuration file. Opening and creating web sites on IIS requires running Visual Studio under an Administrator account.

I tried following, but in vain:

  • Running VS 2017 pro as an administrator.
  • I ensured that I have access to %systemroot%\System32\inetsrv\ and C:\Windows\System32\inetsrv\Config folders.
  • I have installed all IIS compatibility windows features through control panel.
  • Restarted IIS manager.
  • Created virtual directories.
  • Changed registry path of HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal from u:\ to C:\Users\MyUser\Documents.
  • Uninstalled IIS Express 10.0 from control panel and reinstalled it through VS2017 installer by clicking – Individual components – cloud, database server – IIS Express.
  • Repaired VS 2017.
  • Got admin access on machine.
  • Created new empty web project but getting same error while new console app runs without errors.
  • Restarted machine after every installation related change.

All the solutions tried are mentioned on stackoverflow but are not working for me. Is there something trivial that I am missing? Please guide me to crack these IIS errors.

Vahid Farahmandian
  • 6,081
  • 7
  • 42
  • 62
P Deshpande
  • 457
  • 1
  • 4
  • 6

12 Answers12

70

I was able to solve this issue doing the following:

1- Go to C:\Windows\System32\inetsrv and double click on directory config and accept the warning message.

2- Go to C:\Windows\System32\inetsrv\config directory and double click on directory Export and accept the warning message.

Then you will be able to run the app in your local IIS without being an administrator. You can follow the path in the given Image.

enter image description here

jordenysp
  • 2,644
  • 22
  • 17
4

This solved the problem for me with Visual Studio 2017, .Net Core 2.2 and IIS Express 10.

You need to ensure devenv.exe has sufficient permissions. You can find it at:

C:\Program Files OR Program Files (x86)\Microsoft Visual Studio nn.n\Common7\IDE

Right click on the exe, select Properties, Security. I gave Administrators full control as I'm running VS under admin.

enter image description here

Community
  • 1
  • 1
Eddie
  • 411
  • 4
  • 6
  • Thanks man, this is the only thing that solved it for me, using VS 2022 and an old .NET Framework 4.7.1 web project, but I had to give myself (already a local admin) full control of the VS exe. And I always run VS as Administrator. Why one runs into this **just to load a project containing source code** is beyond me. – DvS Dec 31 '21 at 15:26
4

My Simple solution was to right click on Visual Studio and click Run as Administrator. But a solution above tells you how to have Visual Studio always run without having to run as an administrator.

Dwain B
  • 187
  • 1
  • 6
2

All these solutions could not work for me. The issue was, I have accidently uninstall IIS from control panel even it was install and showing me. but was removed from control panel. I reinstall IIS latest version and able to fixed the problem. This might help for others.

This link help me

VS2017 RC - The following error occurred when trying to configure IIS Express

Shahid Malik
  • 163
  • 13
  • 2
    thank you man! you saved my day. After installing .net core 6.0 SDK my IIS was damaged and this was the reason why I was not able to load my .net projects. Re install of IIS solved the issue. thanks! – JamesP Aug 26 '22 at 14:54
1

The issue for me was caused when I modified my project to override application root URL. After a push/merge and new branch my project would not load any longer. reverted the changes and all is well again.

enter image description here

WeisserHund
  • 150
  • 10
1

Restarting Visual Studio worked for me.

NightShovel
  • 3,032
  • 1
  • 31
  • 35
0

Open an elevated command prompt and enter the following command to substitute a drive path for U drive.

c:\windows:\system32> Subst u: C:\Users\MyUser\Documents

I had replaced ‘U:’ path in registry with ‘C:\Users\MyUser\Documents’ previously. I think that was not sufficient. Some references of u:\ might have been hindering IIS. The total substitute command must have replaced all references and the IIS config error got resolved. Hopefully, now I’ll be able to load my web apps.

P Deshpande
  • 457
  • 1
  • 4
  • 6
0

I had the same issue, but instead of the workarounds (such as first double-clicking certain directories each time or running the security risk of always having to always run my VS as administrator), was able to permanently resolve the issue by deleting the "ProjectName.csproj.user" file and that fixed it. I guess there was some incompatible setting in the user file that VS couldn't deal with.

Robert N
  • 1,156
  • 2
  • 14
  • 32
0

For older versions, change the option from IIS to your solution name, before clicking on the green play like run button, to build and run the application.

Ashique Razak
  • 487
  • 3
  • 8
0

We resolved this by removing the project and adding it back.

Tuan
  • 5,382
  • 1
  • 22
  • 17
0

If you're used to run your Visual Studio via shortcut with 'Run as administrator' checkbox marked, double check it is indeed still selected. For some reason mine had unchecked itself resulting in inability to load an IIS project. I was 100% sure my VS had these administrative privileges as usual, which made me try all the Internet proposed solutions except for the most obvious one.

Tarec
  • 3,268
  • 4
  • 30
  • 47
0

at my case, restarting IIS solved the problem

Restarting IIS Server:

  1. Control Panel -> Administrative Tools -> Internet Information Services (IIS) Manager

  2. Click the "Restart" link on the right panel under Manage Server section.

and you may need first to follow the first answer to this question

Ahmad Alaa
  • 767
  • 9
  • 30