This isn't the first time we're talking about the IIS Metabase: we did it already, altough briefly, when we explained how to allow external requests in IIS Express from Visual Studio's debug mode, which could be useful when you need to debug your web application from a mobile device. If you read the previous post, you'll remember that we also suggested switching from IIS Express to the more robust and resourceful IIS 7.5 or above, which is often the weapon of choice for a .NET developer who wants to test his work in a production-like environment since you can use advanced features such as HTTP Rewrite, Server-side encryption/compression, precise MIME-Type / ISAPI Modules handling, advanced Application Pool control & more.
The problem of ditching IIS Express in favor of IIS is often related to the Visual Studio inability of accessing the IIS metabase with the current user priviledges, not giving the user any option option to automatically elevate them. The problem can arise with a popup similar to the following one:
or with an error notice in the Visual Studio Output Window when the Solution tries to load the Web Application's project file:
1 |
error : The Web Application Project Know.WebSite is configured to use IIS. Unable to access the IIS metabase. You do not have sufficient privilege to access IIS web sites on your machine. |
We can fix these kinds of problems in two ways:
- Launch Visual Studio with Administrator priviledges (right-click > run as Administrator...)
- Permanently grant the IIS Metabase folder permissions to the current user.
First options might seem viable but has it nasty set of flaws, the most annoying one being that you won't be able to drag/drop or cut/paste between the Visual Studio Solution Explorer and the Windows Explorer, because the system won't allow the interoperability of two Explorer instances being started with different priviledges.
That's mostly why option 2 is definitely more viable. Put it in motion is really simple, all you need to do is press Win + E to open a Windows Explorer instance, then write the following line on the topmost address bar depending on the OS you're using:
Windows 7, Windows 8.1 and Windows 10
1 |
%systemroot%\System32\inetsrv\config |
Windows 8 Professional
1 |
%systemroot%\inetsrv\config |
As soon as you hit the Enter key the following popup will appear, asking you if you want to permanently grant access to that folder to the current user:
Click on the Continue button, then try to open up the \Export\ subfolder with a couple mouse clicks and repeat the same process.
You're done: from now on, you'll be able to launch Visual Studio with default priviledges and your IIS instance will work without hassles.
Happy coding!
Thank you very much, God bless you!!!
This saved me a lot of frustration, thanks a lot! :)
Thanks very much, this worked perfectly.
Great solution. Thank you very much. Cheeers.