Unable to access the IIS metabase ASP.Net - asp.net

Hi I know there are a few threads on this but none of the solutions seem to work for me.
I have an ASP.Net website project which I am trying to load and publish in Visual Studio. However when I load the project I get the error:
Creation of the virtuald directory http://localhost:xxxx failed with
the error: Unable to access the IIS metabase. You do not have
sufficient privilege to access IIS web sites on your machine.
This error only occurs when I run Visual Studio as Administrator. If I don't run as admin then the above error does not occur but when I try to publish my app I get:
Please launch Visual Studio under administrator mode to perform this
deployment action
It seems I can't win!
What I've tried so far:
Taking ownership of C:/Windows/System32/Inetsrv/Config
Setting <UseIISExpress>false</UseIISExpress> in my project_name.csproj file
Go back to and old team foundation server check in that didn't have the problem in admin mode and use that configuration.
Running Visual Studio as non-admin (works but note second error above)
None had any luck so far.
Extra Info:
Operating System: Windows 8.1 (64 bit)
Visual Studio: 2013
IIS: 8.5
Permissions on C:\Windows\System32\inetsrv\config (read only):
Me: Full control
Administrators: Full control
Permissions on Documents/IISExpress/config (read only):
Me: Full control
Administrators: Full control
Note "Documents" is on a network drive

It turns out my Personal Folder was set to a network drive which occasionally went down causing the error described.
To change your Personal folder:
Open C://Windows/regedit.exe
Navigate to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
Change the field Personal to %USERPROFILE% or %USERPROFILE%\{a folder of your choice}
This fixed the problem for me.
Note you may need to move over any files from your old Personal folder to your new one as they wont be picked up any more

Have you tried the following fix ?
Here is the Fix that worked.
"I think we encountered a similar problem at work. For us, the solution was to go into Control Panel -> Programs and Features -> Turn Windows Features on or off... inside that, we had to select Internet Information Services -> Web Management Tools -> IIS 6 Management Compatibility -> IIS Metabse and IIS 6 configuration compatibility.
https://social.msdn.microsoft.com/Forums/en-US/1d5cb9c7-af77-4bcd-8421-e813aff88bd3/help-with-visual-studio-2012-error-unable-to-access-the-iis-metabase?forum=visualstudiogeneral

I had the same problem after I mistakenly Cut and Pasted my Documents, Downloads and Desktop folders to my external hard drive, it changed the path of the folders to the F: drive (the external hard drive), I copied the folders back and set the path back to local.
Copy the items back to C:\Local Disk\Users\your_name
Right click on the folder (that isn't working) and click Properties
e.g Documents
Click on the Location Tab
Change the location to normal e.g C:\Local Disk\Users\your_name\Documents
This is what worked for me :D

Maybe a shot in the dark - but have you tried installing the 'IIS Management Console', 'IIS Management Scripts and Tools' and 'IIS Management Service' from Add/Remove Programs - Turn Windows Features On or Off? That may help.

Left click on your project --> properties. Select WEB. Check the link [port] on project url. Click Create Virtual Directory. Should help.

Step 1: Close if Visual Studio Opened.
Step 2: Open Project Folder and find ".vs" folder, it may be hidden
Step 3: Delete ".vs" folder
Step 4: Open Project Again

Related

You do not have permission to access the IIS configuration file - Web app error

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.
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.
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.
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.
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
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.
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.
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.
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.
We resolved this by removing the project and adding it back.
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.
Restarting Visual Studio worked for me.

IIS7 MVC Routing Not Working

Our company ships an MVC based product (targeting v4.5) which has stopped working on a customer site for what appear to be environmental issues - a build which worked with no problems once upon a time now gives a 403.14 - The Web server is configured to not list the contents of this directory.
.
What I think is happening...
The user accesses http://server/AppName
Because it's an MVC app, the default route (Reports/Index) should be used.
Instead IIS is looking for a default document...
... and, not finding one, it assumes the user wants to list the contents of the directory...
...which is not enabled so it throws a 403.14.
.
What I've tried so far...
Accessing the route directly.. results in 404 error. So I'm pretty
sure IIS doesn't realise it should use routing.
Use aspnet_regiis to register ASP.Net with IIS. This was done from the Framework64 folder since...
OS is 64 bit - Windows Server 2008 (Standard without Hyper-V)
IIS is 64 bit - though Enable 32-Bit Applications is true
Checked AppPool is targeting v4 of the framework - it is.
Changed AppPool mode to Classic - was pretty sure it should be integrated but was worth ruling it out. It is now back to Integrated
Confirmed RunAllManagedModulesForAllRequests is set to true in the web.config.
Checked permission conditions defined in <system.webServer> section of web.config are met - they are.
Created the simplest of MVC applications and deployed it - same problem.
Running the command shell as Administrator unregistered ASP.Net using aspnet_regiis -ua and re-registered using aspnet_regiis -enable -i. We hit a couple of permission problems - and the Temporary ASP.NET Files directory was missing but once they were address we were back to the same error.
Added a simple default.htm - when present, this is served in response to the http://server/AppName request.
I'm clean out of ideas and all google hits suggest some combination of the above - or enabling directory browsing (which I think is just a symptom rather than the root cause).
Also, not sure if it's relevant but the amount of configurable elements available for the application in IIS seems a bit below what I would have expected...
Have you Checked the user the application pool process is running under? I think Your site needs to run with permissions to execute the .net libraries and I've seen this just change for seemingly no reason (probably related to an overzealous update to the system).
You can try with the Enabling directory browsing .
assuming you are under Windows Server 2012 or Windows Server 2012 R2
On the taskbar, click Server Manager.
In Server Manager, click the Manage menu, and then click Add Roles
and Features.
In the Add Roles and Features wizard, click Next. Select the
installation type and click Next. Select the destination server and
click Next.
On the Server Roles page, expand Web Server (IIS), expand Web
Server, expand Common HTTP Features, and then select Directory
Browsing. Click Next.
On the Select features page, click Next. On the Confirm installation
selections page, click Install. On the Results page, click Close.
if you using the Windows PC try this in your command prompt as follows:
go to C:\Program Files\IIS Express
then press Enter:appcmd set config
/section:system.webServer/directoryBrowse /enabled
Maybe this is your case https://forums.iis.net/t/1157304.aspx
SQL Server Reporting Services creates a folder called Reports by
default if you install it on IIS. If you install SQL 2008 then
Reporting Services doesn't need to use IIS and instead will try to
reserve the URL with the HTTP.Sys service.
I believe this is the cause of the conflict you are seeing. What you
could try is changing the URL that Reporting Services uses via the SQL
Server Configuration Wizard.
Also I found that
Report Manager of SQL Server can use reports path http://<server name>/reports
Configure a Native Mode Report Server for Local Administration (SSRS)
I think the problem is IIS features that are not installed yet. I have met this kind of problem frequently in Windows Pro. Make sure to turn on every feature under Internet Information Service -> World Wide Services because by default IIS is configured to use WebForms. So there might be some features that not installed yet to use MVC, especially ISAPI filters. In my case, that was the solution. I hope it helps.
Something similar i encountered using VS 2017 & ASP.NET MVC.
Was working on the project for long with no problems at all but suddenly the routing started misbehaving & stopped working.
So I changed the Port in Project Properties Page & it started working.
I really don't know what is the relation between a port & MVC routing modules. Someone else can enlighten if at all this helps.
I had the same problem and I just created an application pool out of the Default Web Site in IIS and stoped the default web site. With that difference you will not have the application pool's path
I know it's been a long time since this question but i've had the same problema recently. I've tried every single configuration, just like #amcdermott did, but the only action that solve the problem was reinstalling .NET Framework.
My app was built under .NET Framework 4.5.2. The application server had the version 4.6.1 and 4.5.2 installed. So, i uninstalled all framework versions and installed the one that i needed.
Please, make sure that no other applications use superior versions of .NET Framework if you going to try this solution.
Here are some quote I find on Microsoft official site which I think may help:
For site administrators
This problem occurs because the Web site does not have the Directory Browsing feature enabled, and the default document is not configured. To resolve this problem, use one of the following methods:
Method 1: Enable the Directory Browsing feature in IIS (Recommended)
To resolve this problem, follow these steps:
Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
In the Features view, double-click Directory Browsing.
In the Actions pane, click Enable.
Method 2: Add a default document
To resolve this problem, follow these steps:
Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
In the Features view, double-click Default Document.
In the Actions pane, click Enable.
In the File Name box, type the name of the default document, and then click OK.
Method 3: Enable the Directory Browsing feature in IIS Express
Note This method is for the web developers who experience the issue when they use IIS Express.
To do this, follow these steps:
Open a command prompt, and then go to the IIS Express folder on your computer. For example, go to the following folder in a command prompt:
C:\Program Files\IIS Express
Type the following command, and then press Enter:
appcmd set config /section:directoryBrowse /enabled:true

Unable to access the IIS metabase

An ASP.NET web project loads with up the solution, but I get this error
The Web Application Project 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.
How can this be solved?
This may have nothing to do with registering ASP/IIS. The reason is exactly what the error message says: Visual Studio devenv.exe is not running with sufficient privileges to access the IIS process, and it needs to do this if your solution contains a web project whose Web settings say to use IIS rather than the VS dev server.
There are two solutions to your problem:
Run VS as an Administrator and reopen the solution/project.
Edit the web application's project file with a text editor and change this line
from True to False:
<UseIIS>True</UseIIS>
That will stop it using IIS and demanding higher privileges.
The reason VS demands Admin privileges is, I believe, because it will try and create the IIS web site for you on demand if it doesn't exist.
An answer that worked for me can be found here:
https://stackoverflow.com/a/17460774/3005965
Basically, go to %systemroot%/inetsrv/config. When prompt appears saying you need admin privileges, click Continue.
This should clear up your issue.
Just try to access Visual studio as Admin right click and choose run as administrator.
may fixes this problem.
and take a look at this link for instructions on creating a shortcut.
I ran into this problem when I had copied a project to a new project. I opened the project file (.csproj) and removed the value from the IISUrl element:
from: <IISUrl>http://localhost:21222</IISUrl>
to: <IISUrl></IISUrl>
Have you registered the .NET framework with IIS? You need to run the aspnet_regiis.exe utility found at %WindowsDir%\Microsoft.NET\Framework\vx.y.zzzz\. Run it as administrator as follows:
aspnet_regiis.exe -i
-i : Installs the version of ASP.NET that is associated with Aspnet_regiis.exe and updates the script maps at the IIS metabase root and below. Only the script maps for applications that use an earlier version of ASP.NET are updated. Applications that use a later version are not affected.
Find out more about the utitlity here.
This error also occurs if you modified your Machine.config and added some "invalid lines":
For example, I added some appSettings, to the configuration section (which IIS didn't like).
Just register your Web-project in your local IIS. All the settings you will find in *.csproj file. That works for me.
first uncheck internet information service from turn windows features on or off.
then uninstall iis from your system and restart it. after restarting it install iis again from https://www.microsoft.com/en-us/download/confirmation.aspx?id=34679 and try to open again.
Step 1: Close Visual Studio
Step 2: Go to Project Folder and find ".vs" folder Note: It may be hidden
Step 3: Delete ".vs" folder
Step 4: Open Project Again

AnkhSVN breaks ASP.NET sharing permissions with SVN 1.7

The Background (skip to the bottom if you want the question)
Recently I upgraded an SVN repository (hosted on assembla) to SVN 1.7. After doing so, we started to intermittently encounter lots of File Access Denied errors on the ASP.NET site pages that sit in the local working copy of the repository.
Some folders also started to get weird file permissions (they became marked read-only) and user sharing got removed from them. These problems would only start occurring after an update/commit cycle, via AnkhSVN's Visual Studio plugin, but not all the time; it seemed highly temperamental.
The only temp-fix we've found so far is to commit any outstanding changes, delete the local copy and re-checkout a full working copy (with TortoiseSVN). However, that is not a viable fix, and it is seriously impacting on productivity.
This site is an Azure based ASP.NET WebWorkerRole. It has never given problems before the upgrade to SVN 1.7. I tried fiddling with the internal IIS permissions to get around the problem, however, no dice.
My Environment
Visual Studio 2010 Ultimate 10.0.40219.1 SP1
AnkhSVN 2.3.10509 (latest version, supports SVN 1.7.1)
TortoiseSVN 1.7.1, Build 22161 - 64 Bit
Running in Debug Mode via the Azure emulator environment
The Question
Is it possible for SVN 1.7 or any of the tools in my environment to break file permissions so that the files become unusable in an ASP.NET site? and more importantly, how do I fix this?
The exact file permission error dumped out is this:
Access to the path '//file//' is denied.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the
path '//file//' is denied.
ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request
identity. ASP.NET has a base process identity (typically
{MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and
the configured application pool identity on IIS 7.5) that is used if
the application is not impersonating. If the application is
impersonating via , the identity will be
the anonymous user (typically IUSR_MACHINENAME) or the authenticated
request user.
To grant ASP.NET access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add
the appropriate user or group. Highlight the ASP.NET account, and
check the boxes for the desired access.
But a clean working copy will not generate this error. Comparing the permissions of the two, it seems the working copies that are not bugged are shared (with IUSR and the local account), whereas the broken ones have zero sharing, yet the sharing is never changed by the user.
When subversion updates a file it first creates a temporary version in .svn/tmp/. It then moves the file into the right location. (This to avoid corruptions)
In 1.6 it did this for every directory by itself, but in 1.7 there is just a .svn in the top level directory of your working copy.
If somehow the filesystem permissions of this .svn directory are restricted, it is possible that the restrictions are copied with the file when it is moved in place.
(Subversion doesn't change the permissions itself on Windows)
I solved this by accessing the security settings for the website folder and and clicking Advanced and then Change Permissions for the IIS_IUSRS user. I checked the "Replace all child object permissions with inheritable permissions from this object" and clicked apply.
Before that, I had given the IIS user full permissions to the hidden tmp folder in the root of the checkout, but I don't know if this helps with anything.
I'm not sure if this is a permanent fix, but in case it is not, you can at least use it to reapply permissions for all the files in a single operation.
Much information is located in .svn folders inside directory where project was checked out. So in my opinion better use SVN separately from advanced integration tools. Also this deals with solving problem like this.
I found this exact same issue happened when I did a 'Revert' using:
Tortoise Svn 1.6.16
AnkhSVN 2.3.11269.1348.
Visual Studio 2010 Professional
Windows 7 - 64 bit.
I was completely puzzled the first time I encountered the permissions error and started off by thinking it was my code. After a while of fiddling about I ended up deleting the whole project and re-downloading from Subversion which fixed the issue.
When this problem happened again I looked more closely at the reverted file, and I found the permissions on the reverted files do not match the permissions of the other files. Specifically 'Users' permissions, for the machine that Visual Studio is running on, is missing altogether.
So I just added it in by:
Right clicking on the problem file. This caused the file properties window to appear.
Then clicked on 'Edit...'. The permission window appears.
Then clicked on Add and the 'Select Users, Computers, Service Accounts, or Groups window appears.
Click on the Object Types button and check all the boxes.
Click on the Locations button and make sure your machine name is selected.
Type in 'users' then click the 'check names' button.
Click OK on all the windows to close them.
Your website should now run without the permissions error.

Publishing an ASP.Net web application to a mapped drive with Visual Studio 2008 and Windows 7

We have a shared drive where web applications are published to. When I attempt to publish I get the following error:
------ Publish started: Project: XXX.Web, Configuration: Release Any CPU ------
Connecting to T:\WebSites\XXX\...
Unable to create the Web site 'T:\WebSites\XXX'. The path 'T:\WebSites\XXX' does not exist or you do not have access. The system cannot find the path specified.
Details
OS: Windows 7
IDE: Visual Studio 2008 (running as administrator)
Path exists? Yup.
I assume it's some permissions issue, but I have no idea where to start.
If anyone is still wondering, I had this same problem in Visual Studio 2012 with MVC4 in windows 7. I had previously published to a mapped drive and now all of a sudden it would no longer publish. In windows explorer I could see the mapped drive, but visual studio claimed it could not find the drive.
It turns out that if you are running visual studio in admin mode and your drive wasn't mapped in admin mode, you have to remap it.
(solution)
To do this, run explorer in admin mode, and then re-map your drive. Afterwards visual studio should be able to see the drive again.
I had this same problem with VS2010 and what worked for me is to click the [...] button next to the target location and rebrowse to the destination folder. Could be that VS is showing one path in the publish and output window, but really trying to access some other folder that's protected in Win7. That's why it worked in XP and not Win7 because Win7 has many more secure folders.
There are two points of check.
Share permissions.
File permissions.
You can both found on the remote computer, right click on the folder name -> permissions, and you see the Sharing and the Security tab. Change them, to left you write.
Help: how to share files:
http://www.howtogeek.com/howto/windows-7/share-files-and-printers-in-windows-7-with-homegroup/
and a video tutorial about :
http://www.youtube.com/watch?v=BWB9pu1T2dQ
Video tutorial for share folder base on my answer
http://www.youtube.com/watch?v=OomgNBAv0hI&feature=related
When you say administrator I will assume that you are an administrator to both the computer and the server containing the mapped drive. If that is the case then,
You might want to give this a shot:
To resolve this problem, add a MIME type for the .tmp file in IIS. To do so, follow these steps:
In Control Panel, open Administrative Tools, and then double-click Internet Information Services.
Expand the (local computer) node, and then expand Web Sites.
Right-click Default Web Site, and then click Properties.
In Default Web Site Properties, click the HTTP Headers Tab.
Click MIME Types. In MIME Types, click New to register a file extension.
In the Extension textbox, type .tmp . In the MIME Type textbox, type temp.
Click OK.
http://support.microsoft.com/kb/817264
If you are not in "Admin" mode and you are still having the issue, you can copy the "Target Location" path setting in your publish profile in VS, and then go to the file menu and check if you have access to that location, if you are prompted to enter user credentials, enter your credentials, this will allow Visual Studio to have the credentials needed. Now, go back to the publish profile and retry, it will use the credentials you just entered.

Resources