Reputation: 507
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:
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.
Upvotes: 34
Views: 46926
Reputation: 426
I had the same problem on Windows 11 for ARM + Visual Studio 2019. Here is how I fixed this issue:
Upvotes: 0
Reputation: 2794
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.
When opening the files in Windows Explorer, accepting the security prompt adds your user to the permissions list for that directory. To do this manually, you would open the security tab of the folder properties, and add your user to the list of permissions on both directories listed above.
Upvotes: 81
Reputation: 817
at my case, restarting IIS solved the problem
Restarting IIS Server:
Control Panel -> Administrative Tools -> Internet Information Services (IIS) Manager
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
Upvotes: 0
Reputation: 160
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.
Upvotes: 2
Reputation: 3255
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.
Upvotes: 0
Reputation: 685
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.
Upvotes: 0
Reputation: 1174
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.
Upvotes: 0
Reputation: 171
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
Upvotes: 2
Reputation: 197
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.
Upvotes: 4
Reputation: 429
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.
Upvotes: 5
Reputation: 507
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.
Upvotes: 0