Visual studio 2019 “Unable to connect to web server 'IIS Express'” - c#

I attempt to lunch my ASP.NET Core project in Microsoft Visual Studio 2019 and got this error: "Unable to connect to web server 'IIS Express'"
Visual Studio 2019 Version 16.9.5
.Net 5.0

I tried this one and it worked for me:
Go to 'Debug Properties'
Find 'Web Server Settings'
Change the port in 'App URL' section and save the changes
Run the application and the same error will appear again
Switch the port back to the original port and save the changes
Run the application and enjoy it!
I hope this trick work for you.

If rebooting fixes this for you, then do this instead:
net stop winnat
net start winnat
The problem is that something reserved your desired port and made it unavailable.
See https://superuser.com/a/1610009/239292

1- Go to 'Debug Properties', Find 'Web Server Settings', Change the port in 'App URL' section and save the changes
In your project folder, delete .vs file, also remove the launch settings file in properties (make sure you copy to a different folder before removing it).
Restart visual studio and your machine if possible. Go to launch setting, check if they are properly configured similar to your prev launch settings. Run the application in IIS.
Should start working.

The following fixed the problem for me.
Delete the "properties\launchsettings.json" file.
The above solution has worked for other users too as per https://developercommunity.visualstudio.com/t/unable-to-connect-to-web-server-iis-express-in-vs/1027196

I encountered the same issue , but after few seconds i find out that there is a duplicated sslport , the same sslport being registered for another running app , so when i run another app with the same setting i see this error , you have to change the sslport in the launchsetting.json

From my experience this issue appears when the port used is already in use by other process. You will see the following:
Error description: The process cannot access the file because it is being used by another process. (0x80070020)
Just choose a port number which is free to use and the problem will disappear!

To me it has worked by switching the project from Debug to Release and Starting it.
When I switch back to Debug it starts correctly.
It appears to me that For some reason i had the Release project running so the Debug couldn't start.

I have just an API project.
Going to project's Properties\Debug and unchecking the 'Launch browser' helped.

In my case... (Visual Studio 2019, .net 5, blazor wasm project):
I did bkp copy of "Properties\launchSettings.json" file and ".vs" folder (just in case)
I deleted the "Properties\launchSettings.json" file and open the solution.. This file is recreated with default values...
After that, the error is gone and I was able to run and debug the application normally.
Now you can redo your updates on the "Properties\launchSettings.json" (i.e. change port).

In my case it was the wrong .net6 version. I work in a project with other developers. The main developer switched the project from .net5 to .net6. He has 6.0.3 installed, I have 6.0.2. Visual Studio did not show this. On the console with dotnet run, I get this error message.

My error message was regarding Kestrel web server: Visual Studio is unable to connect to web server... the web server is no longer running. I had to replace applicationUrl values from https://0.0.0.0:5001 to https://localhost:5001 . I got this error when I updated Visual Studio 2022 to 17.3.0

If you are like me and have probably tried all the above answers to no avail, here is a final solution that has helped me many times.
Answer: Do not restart your system (did this and it failed to work for me most times), rather, save all your work items, then shut down your system to allow all running process to shut down, then power on again.
If you do a restart, IIS Express may not get shut down completely, therefore, your port will still be used by the process holding on to it.
This works for me always

not sure if this answer will help anybody but I had made changes in appsettings.json file in Asp.net Core (net 6) and forgot to add coma after curly brackets
{
"AppSetting": {
"Token": "MY TOKEN"
}, ----------------------->here
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Hence: you might find your errors in your warnings

Related

ASP.NET 5 MVC: unable to connect to web server 'IIS Express'

What I'm doing:
Opening Visual Studio Community 2015
File -> New -> Project
Under Visual C#: Web -> ASP.NET Web Application
Web Application
And press f5 for the popup error "unable to connect to web server 'IIS Express'."
Deleting applicationhost.config, located in Documents\IISExpress\config, doesn't change the error message. (There's also an IISExpress folder in program files and program files (x86).)
Something I noticed, and I don't know if it's a problem:
Referenced file 'lib/jquery-validation/jquery.validate.js' not found.
I got a dump with rawcap but I don't notice much in there. Some of what was there:
"Framework":{"FrameworkName":"DNXCore,Version=v5.0","FriendlyName":"DNX Core 5.0","ShortName":"dnxcore50","RedistListPath":null}
I don't notice a problem, but I have the network data if that can help figure out why I cannot connect to the web server. I get a RST,ACK immediately so I'm guessing the port is closed and whatever this web server is, isn't being setup.
More on this problem: 800700c1 error from /trace:error
I've tried:
deleting applicationhost.config (and changing port number)
running visual studio as administrator
deleting IISExpress folder in Documents (changes error message until the folder is reinstalled)
toggling ssl off and on, copying url to launch box. (note: I'm not using ssl)
clearing all sfc /scannow errors
starting iisexpress with x86 version and 64-bit version
After installing Update 2 for Visual Studio 2015 I started getting the same error. I tried everything above with no luck. However, I found a solution that works for me:
Delete YourSolutionFolder\\.vs\config\applicationhost.config file (note: .vs is a hidden folder)
Open Visual Studio, right-click on web site > Properties > Debug tab > Web Server Settings > App URL - change port number.
If you have IIS configured to use the same port, (stop the application / use different port) and try again.
Exit VS and delete the (project)\.vs\applicationhost.config file. Restart VS. It should start working.
Try using a different port. I just set up a new Core 1.0 RC1 project and got the same error.
Right click web project
Debug tab
Toggle Enable SSL off and on again, it should generate a new random port
Copy the SSL URL and paste into Launch URL box
Run the project
Worked for me (TM).
Answer from: https://stackoverflow.com/a/28650554/134761
I had this issue on .net core 2.1, visual studio version 15.9.6. When i deleted the .vs folder, i reopened visual studio and the problem was still there. The solution that worked for me below:
Delete .vs folder (it is a hidden folder).
Restart Computer.
Other Solutions:
Close Visual Studio, delete bin and obj folders from the project folder. Open Project then rebuild solution.
Try running Visual Studio as Administrator.
Clean Solution then rebuild
Clean Solution. 2) Exit Visual Studio. 3) delete .vs folder 4) Re-open Visual Studio
Restart machine (if you can afford to)
Copied my comment to an answer by request.
For Net Core 2.2 project - After a MASSIVE struggle and trying everything from deleting .vs folder, deleting IIS Express configs, changing port numbers, changing bindings, and to running VS as admin I FINALLY fixed issue by
closing VS,
deleting launchSettings.json
opening VS which re-generated launchSettings.json.
It was not apparent that the file was corrupt or incorrect or even when it changed to cause failure.
I faced this issue in .net core 2.0 when I update my project's port number.
I was able to sort out issue in two steps :
STEP 1 : DELETE .vs folder which is hidden inside main solution folder. (close visual studio before this) then when you start again visual studio, this folder and file (applicationhost.config) inside it will automatically create by visual studio.
STEP 2 : For multiple startup projects, if you are still facing issue then one by one run project as startup, and then run as multiple startup project.
I had the same issue, i was able to solve it by changing the Port number.
Right click on the project and select properties
Go to the Debug section
Under Web Server Settings change App URL port [just increase by one :)]
In my case that was some other application listening on the same port which IIS Express trying to attach to. I have to run netstat -ao to see PID of process which is use same port and shutdown application. In my case application was Viber.
I just changed my profile from "IIS Express" to "MyProjectName" (which I think is using kestrel as the http server instead of IIS) and now it's working fine:
Run VisualStudio with administrator privilegies and run the project. Then close VisualStudio and all errors and run VisualStudio again with the normal user.
This did it for me.
Looks like that IIS has to write something to some config with admin privilegies (port 80 didn't work with normal user but port 6767 worked fine).
Many of these answered don't fully address the issue at hand. The real problem for me was that I had two bindings using the same port in my applicationhost.config file AND I hadn't opened up the port to my second (non localhost) binding. VS will allow you to still run under these circumstances but only if you are in admin mode (hence all of the answers above).
You are essentially creating two IIS express instances of your app on the same port, so changing one of the ports in your applicationhost.config file will allow you to proceed. There are two different applicationhost.config files however. You will want to select the one that has the binding IP and port that you see in your project's properties
.
Go to the folder where you can see your project solution and project folders (show hidden items in File Explorer). Navigate into your hidden .vs folder -> "YourAppName" folder -> config. It should contain the binding info you saw in your project's properties.
Example:
<bindings>
<binding protocol="http" bindingInformation="*:7000:127.0.0.1" />
<binding protocol="http" bindingInformation="*:7000:192.168.0.5" />
</bindings>
Change one of those port numbers to something other than "7000" so that you aren't trying to use the same port.
In my case, I'm using a 192 address which is not a localhost address, so I need to use some netsh commands to open that port and ip up. Here is a Link that shows how to open up ports for IIS Express to allow remote connection. Running as a normal user will not work unless you run those netsh commands listed.
Here are the netsh commands:
netsh http add urlacl url=http://192.168.1.42:58938/ user=everyone
netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=58938 profile=private remoteip=localsubnet action=allow
Copy those commands and run them in cmd with ADMIN privileges and with YOUR ip address and port number.
TO CLARIFY
Really a lot of answers here are the same and say something like "Restart and it magically works again".
Well, 9 out of 10 times people have this issue like the OP it is because THE IP-ADDRESS IS ALREADY IN USE.
ANSWER
There could be 2 ip-addresses that are in use. Both of them you can find by:
1) Right-clicking on the start-up project
2) Click on "Properties"
3) Click on the "Debug" tab
Here you see your "App URL" and your "SSL URL".
If your "App URL" is in use, just change it there and save it and it should work again.
If your "SSL URL" is in use, close down VS, delete the "applicationhost.config" file in the hidden .vs folder of your project and open VS up again.
The solution that worked for me was to:
Close the VS project
In File Explorer, navigate to the project and delete the entire ".vs" folder
Restart the project
Run as "Debug"
Works
Apparently, it has something to do with the "applicationhost.config" file.
Enjoy!
If you can afford to restart your machine then do it 👌, this fixed my issue after almost an hour of trying to fix this issue with no hope 🤯.
I was able to toggle this error by changing a single thing. In my ASP.Net Core 1.0 RC2 Web Application project's launchSettings.json file:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:18177/",
"sslPort": 0
}
},
to
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18177/",
"sslPort": 0
}
},
I had changed to https in an attempt to run the project using that protocol. Apparently this is not the place to make that change. I suspect it is creating multiple bindings on the same port, and IIS Express doesn't like that.
I had this same issue, but the way I fixed it was by going to the applicationhost.config and remove a port which was not added by me (IIS Express I would guess) which placed my specific port site on another port.
Here is what the config file had for my bindings:
<bindings>
<binding protocol="http" bindingInformation="*:54764:localhost" />
<binding protocol="https" bindingInformation="*:44360:localhost" />
</bindings>
I removed the first bindings item as the only port I wanted was 44360. My config file now looks like this:
<bindings>
<binding protocol="https" bindingInformation="*:44360:localhost" />
</bindings>
Now I don't see the error when I debug.
I also noticed my second API in my project had port 80 also assigned to it, I removed that as well.
delete bin and obj folders from the project folder and rebuild.
For me the problem was that an other process was using the same port. (In my case it was outlook that was using the same port as my site and thus my site couldn't start)
Yes you can change the local port, but if you are running an API or something that other applications need, you don't always want to do this.
To get a list of what applications are using what port open CMD and type "netstat -aon"
You will get a list of ports. Find the port that your site should use, or that you want to use and write down / remember the PID.
Now open task manager and click on the tab 'details'. Find the process with your PID and end it. Now you should be able to start IIS Express with that port.
I just Cleaned my solution, Then Re-Built it and finally hit F5 and it worked! So simple.
I won't pretend to fully understand what MS bug creates this problem, but here is another potential solution:
In the .vs/config/applicationHost.config file, find the section for <system.applicationHost><applicationPools>. Under the pools, ensure that the managedRuntimeVersion attribute value matches the value which is in the IIS config for the system (and/or the version of the .NET framework which is installed).
For example, you may find (as I did) that the generated file has:
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
In my case, you would replace this with:
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0.30319" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
Note the replacement from "v4.0" to "v4.0.30319". This resolved the issue.
What appears to be going on:
I believe that VS is generating an applicationHost.config file with "default" versions for the .NET framework, which may not match the specific version which is installed/configured on the system. You can debug/observe this issue by tracing the execution in Process Monitor, and finding the command line for iisexpress.exe. Running this command with /trace:error added yields a more informative message about a failure to preload the CLR with version v4.0. To wit:
Starting IIS Express ...
Failed while trying to preload CLR version v4.0. hr = 80131700
Failed to initalize the W3WP_HOST hr = 80131700
Process Model Shutdown called
Unable to start iisexpress.
Anyway, figured this might be helpful to someone else, since it's common enough to have multiple references online with bad information, and I've personally hit it a few times now.
For me, IIS Express was not accessible when I added iplisten on DOS Prompt like this: netsh http add iplisten MyIPAddress. I fixed it by deleting the iplisten like this: netsh http delete iplisten MyIPAddress.
If you are using VS 2017 or VS 2019 with ASP.Net Core, you can directly go to launchSettings.json under Properties folder and just change the Port number of applicationUrl key for iisSetting.
I just encountered the same problem and I killed all the "iisexpress.exe" processes that were still running. That worked for me!
Try this first if it was working and suddenly stopped:
Close Visual Studio
Kill iisexpress.exe processes
Reopen Visual Studio
Mine happens as soon as I add a new binding inside the applicationhost.config, running as administrator fixed the problem.
Just close the visual studio and reopen and execute.
It worked for me.
My solution (for .net core 2.0) was that i had forgot to add the port number in the applicationUrl, under iisExpress in launchSettings.json
"iisExpress": {
"applicationUrl": "https://localhost:50770",
"sslPort": 50770
}
I was able to resolve this by restarting my computer. I tried a few things unsuccessfully and finally gave up and restarted my computer. It has been working well now for a couple of days after I restarted. Probably the result of some process that was hung.
For me, it was a mixture of following these instructions:
Delete your web application’s .vs\applicationhost.config and try
again.
And then, perhaps most importantly, running Visual Studio with admin privileges.
I added .UseUrls("https://localhost:<some port>/") to the Program.cs. This seemed to do the trick for me!

Microsoft Visual Studio 2013: Cannot Create a new Asp.Net project

File -> New -> Website -> ASP.NET Web Forms Site -> OK
Configuring IIS Express failed with the following error:
Filename: redirection.config
Error: Cannot read configuration file
So I've tried several solutions. I checked and already have IIS Express installed. I also am running as admin. I don't know what else to do and googling just tells me to turn it on (it's checked in my tools options)
File -> New -> Project -> ASP.NET WebApplication -> Web Forms Template -> Ok
Unspecified error(Exception from HRESULT: 0x80004005 (E_FAIL))
Are these related? Why can't I do anything related to ASP? My Documents folder is not encrypted.
Result:
I eventually got a new computer where this problem did not occur, so I did not personally solve this problem. Sorry.
I was having the same issue. Here's what worked for me.
Close Visual Studio.
Navigate to your Documents folder, and then the IISExpress subfolder.
Rename the "config" folder to something else. "configBACKUP" will do.
Open Visual Studio and try to create a new ASP.NET project.
IISExpress will create the necessary .configs in a brand new "config" folder.
Same issue due to having IIS Express 10.
Resolved by clicking Repair on it in Programs & Features.
Took 5 seconds and it was fixed.
User\Documents\IISExpress\config files try to uncheck Read Only property
In my case it worked fine after I went to IISExpress folder Documents\IISExpress\config and unchecked the "encrypt content to segure data" cause by default win 8.1 will encrypt it.

Error - Unable to access the IIS metabase

After installing Visual Studio 2012 and opening my solution I get a series of errors in this form:
The Web Application Project Foo 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.
I get this for each of our web applications.
Things I have tried:
Running Visual Studio as Administrator
Running aspnet_regiis.exe -ga MyUserName
Running aspnet_regiis.exe -i
These seem to be common solutions for this problem but I have not had any success with them.
Is there anything else I can try to do?
On Windows 8 Pro:
%systemroot%\inetsrv\config
On Windows 7 and 8.1 and 10
%systemroot%\System32\inetsrv\config
(Where %systemroot% is usually C:\Windows)
Navigate to the appropriate location above in Windows Explorer. You will be blocked access with a popup which says:
"You don't have access to this folder - Click continue to permanently get access to this folder"
Click 'continue' for this folder, and with the Export folder underneath. I changed the shortcut back to "Run as me" (a member of the domain and local administrators ) and was able to open and deploy the solution.
I think you are not running visual studio with administrator permissions. Look that:
http://bloggingabout.net/blogs/rick/archive/2012/10/04/unable-to-access-the-iis-metabase.aspx
To quote
The solution to this is simple: start your Visual Studio with "Run as
Administrator". You can do this by right clicking the shortcut and
selecting "Run as Administrator".
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 Metabase and IIS 6 configuration compatibility.
Give that a try and let me know if it helps!
Note: We're running IIS 7.5 on Windows 7 using both Visual Studio 2005 and 2010 and doing stuff with super-old-school WebServices (.asmx)...
I resolved this issue by granting IIS AppPool identity permissions to the %systemroot%\inetsrv\config
If you are working on a project which does not require the use of IIS, then a workaround to open the project with this error is to simply right click on the unloaded project and click edit, search for:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="">
<WebProjectProperties>
<UseIIS>True</UseIIS>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
and set USEIIS to false
<UseIIS>False</UseIIS>
reload the project by right clicking on it after saving changes.
I have had two seperate types of problem lead to this error, and thought I'd share...
1. The directory was on an network share and due to UAC restrictions, was
unable to be accessed -- even when running as an admin.
2. The directory was on a drive that didn't exist...
Both of these stem from an unfortunate (imo) choice by MS to put things in the Documents or My Document directory, combinee with really lousy error messages. In both of the above cases the fundamental problem was that the IISExpress Config file goes in My Documents, and it either didn't exist or couldn't be accessed.
Thank you to everyone that answered. Since this was closed for a long time I couldn't provide much feedback, but I did eventually fix my problem. I tried many of these other solutions and they didn't fix my issue, but I'm sure they help when the root cause is different.
My Solution
I solved this problem by turning off the IIS and .Net Framework features within Windows 7 and then turning them back on. It seems like this re-installation is what fixed my issue. I still don't know what caused the problem, but at least one other developer on my team had the same issue.
Navigating to folder: %systemroot%\System32\inetsrv\config presents a security dialog. Click continue and this may resolve the issue. This has worked on two separate Win 10/VS 2017/IIS machines.
On a windows 81, from an admin command prompt, use:
icacls "C:\Windows\System32\inetsrv\config" /t /grant "IIS AppPool\DefaultAppPool":(R)
Then go back in VS, right click on the failed project, choose Reload.
Credit to: IIS7 Permissions Overview - ApplicationPoolIdentity
I had this problem - the symptoms were the same, but the issue I had was that I had set the "My Documents" folder to be on a network share, and the share was not accessible.
The root problem was that the IIS config files located at %USERPROFILE%\Documents are not accessible. Once I changed the "My Documents" folder location (I modified the reg value), it started working again.
I know that this may not be a common scenario that you might run into, but I've posted it here because it gives the same symptoms.
I came across this today and fixed the problem by removing the IISUrl from the Project file:
Right click project
Click Edit
Delete the following line:
<IISUrl>http://localhost:xxxxx </IISUrl>
Reload project
Now add a new IIS virtual directory by right clicking Project > Properties > Web and selecting Use Local IIS Web Server (Uncheck Use IIS Express) and clicking the Create Virtual Directory button.
You might run across this problem and have same problem as me. I "solved" it before and then power outage and computer crashed, not sure why a registry setting reverted but it is the SOURCE of my problem.
I tried all the running as adminstrator
All the IIS / IIS express re-installs.
Various "hacks"
Came down to having to fix the registry again.
Could not as administrator even open regedit (Need to access registry since problem is not with gpedit.msc admin template )
UnHookExec.inf on desktop
Just save UnHookExec.inf and install it by right clicking and selecting install. Installing the file will not show any popup or notice box.
http://www.tweakandtrick.com/2011/04/enable-regedit-registry-editor.html
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal pointing to non-existant fileshare. Changing that to local path solved this problem for me. – Pasi Savolainen Jul 14 '14 at 8:41
(changed from \\cs2data\home\stickelt\my documents to c:\dev )
Now ALL is good and Visual Studio opened solution with 15 projects and connects to IIS and does not complain about not being able to access iis metadata
I had never ran into this before, as nobody at current job had this problem ( many have been here a long time, some got clones of other machines that "worked" and many are on another domain etc.. )
I just had this issue today and I found that I didn't open VS as 'Run as Administrator'.
After doing this, I was able to publish the Service.
If you have administrator permissions, Right Click to Visual Studio icon > properties and then advanced, "Run as administrator" check.
You can run visaul studio as administrator directly anymore.
This way, formal and so basic.
In addition to the answer by #nologo, I also had to use IIS. So I changed the
<UseIIS>True</UseIIS>
to 'False' first.
Opened the solution and ensured that the project could be loaded.
Close solution and that instance of Visual Studio
Change the value to 'True' again
Open the solution.
This time, I didn't get any error/warning. I could also run with Ctrl+F5 or F5 without any problem while my project was mapped to an IIS website.
Changing this key worked for me:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal
The location didn't exist.
Go to the root directory of your project and find the following file:
YourProjectName.csproj.user - inside it, make sure UseIISExpress is set to false:
<UseIISExpress>false</UseIISExpress>
If that alone doesn't work try the following as well and try again:
YourProjectName.csproj - inside the main project file, make sure both UseIIS and UseIISExpress are set to false:
<UseIIS>True</UseIIS>
<UseIISExpress>false</UseIISExpress>
After changing these I was able to load the project again.
Note: Make sure you run your VS as an Administrator, as mentioned in the other answers.
I also had a similar problem. My solution is an extension to the answer "Run as admin" which I hope someone might find useful.
I was running VS2012 and almost every time I had to do the Right Click, Run As Administrator. I got tired of this so instead I went into its properties on the shortcut, clicked advanced, and then clicked the "Run as Administrator" option. Now VS2012 always runs as administrator whenever I open it from that shortcut.
The from that shortcut bit is important. I proceeded to branch my project, and download the branch to a new local folder. Then, when I opened it from the shortcut I had no problem. But if I went directly into the folder, and ran the project locally without the shortcut, it did not run as administrator and I got this error.
Once I opened VS2012 as usual first, then using File/Open/Project It worked again no problem. (because I was running as admin). But I wasn't running as admin when I opened the solution using windows file manager.
The other suggestions seem somewhat extreme, but this is pretty simple so I would tend to give this a try first.
Hope this was helpful.
This seems like one of those "All errors lead to this message" type of bugs.
Mine was that the App Pool was just turned off. I turned it back on, and everything worked fine.
One more thing you could try:
Check if you have pending Windows updates.
If you do, please reboot before trying anything else.
I tend to never shut down my machine, so I had plenty of them waiting for a reboot. And that fixed it.
I tried everything above. The credit goes to all of the responses above. Having tried all of the suggestions on their own, I just assembled this combination of suggestions in an order that made sense to me. Note my Documents folder is on a shared drive. The subst/IISExpress stuff is not applicable unless you're in the same boat.
Configure VS to run as admin
Uninstall IIS via Add/Remove Programs, Windows Features
Reboot
Run WinRAR or something similar as admin and archive C:\windows\system32\inetsrv\
Run cmd as admin and rmdir /s c:\windows\system32\inetsrv\ to completely remove all traces of the last install. Leave elevated cmd prompt open for later.
Reinstall IIS with IIS 6 Metabase compatibility (doubt this was necessary)
Leave Default AppPool and Default Website as-is (I had previously deleted both)
Ran C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ga MYDOMAIN\scottt732
Ran C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Also, because my Documents folder is on a share drive, I was having IIS Express issues. I don't use/like IIS Express, but Visual Studio complained about it.
From elevated cmd prompt, ran subst U: c:\Temp. Created C:\Temp\Documents\ and copied the IISExpress folder from my U drive.
Created CustomUserHome key in HKCU\Software\Microsoft\IISExpress with C:\Temp\Documents\IISExpress
This allowed me to get Visual Studio to open my web projects and edit the properties. I tweaked the projects to store web server settings in a user file and adjusted it to use a Custom URL (not sure if this was necessary)
I may/may not have to run the subst command each time I restart. Don't care.
And after throwing in the towel 3 times and spending roughly ~6 hours I can open web projects in Visual Studio (2015 Update 2).
I just had the same issue with me today. And I found it annoying. Though I have other two websites already under development from the same IIS but still was not able to create new site. Strange, but I did this.
Delete the site from IIS
Create new site, give it a name "new_site"
Select Application Pool other than the site name itself. So it wont be messing up with default settings.
Keep IP "unassigned" if you are running it from same machine
give it some unused port
Run Visual Studio as "Run as Administrator" by right-clicking on VS executable shortcut.
You are done!
You do not need to turn off/re-install anything other than what I have stated since it works.
Let me know if anybody had the same issue just like me and solved the same way. I think it was not the issue but a wrong way of creating website on localhost which Visual Studio rejects to open.
I hope this will help newbies.
Create a shortcut to the "devenv.exe"
select the "Run as administrator" option for the shortcut
doble click on the short cut and reopen your project
I had the same problem after Adding feature from this link afterward I followed this article the issue was gone.
I did a repair of Visual Studio 2015 to solve this.
The repair took a long time, but it solved the issue while doing much of the above did not. I am running Win 7 enterprise.
Open visual studio command prompt and type below command and run
aspnet_regiis -ga machinename\ASPNET
After running the above command Reset the IIS and test the application that resolve your issue.
If above command doesn’t resolve your problem then try to run below command in visual studio command prompt:-
aspnet_regiis -i
Alternatively we can run above command from our windows command prompt also
Go to the Start menu and open Run and enter and click OK
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe –I
After that Reset the IIS and test the application that resolves your issue
In Visual Studio 2015:
I changed UseIIS in .csproj file to false and it worked for me.
<UseIIS>False</UseIIS>
In my message, beside complaining about "Unable to access the IIS metabase", it also mentions can't access "<IISUrl>http://localhost:6416/</IISUrl>". Right click on the unload project, click Edit, find the line "<IISUrl>http://localhost:6416/</IISUrl>", comment it out. Reload and it should work. This has to do with administrator doesn't have permission to access that address.
I had a similar problem. Visual Studio would not load any web projects and showed the error: creation of virtual directory <myproj:myport> failed. Unable to access the IIS metabase.
In my case it was actually IISExpress that was at the root of the problem. Right clicking on IIS Express in Programs and Features in the control panel and choosing repair fixed the issue in less than two minutes.
I'm using Win 8 Pro and VS 2013.
After trying everything in this page... I simply reinstalled IIS Express 8 and everything works fine now (even without running as an admin).
My conclusion is that this is a rather generic error and there are multiple root causes.

The Web Application Project [...] is configured to use IIS. The Web server [...] could not be found.

I have a web project in my solution file that is "unavailable" when I open the solution. When I right-click on the web project and reload the project, I get the following error:
The Web Application Project mycompany.myapp.mywebproject is configured to use IIS. The Web Server 'http://localhost/MyWebApp could not be found.
I have not manually set up virtual directories for this web application.
Per colleagues, Visual Studio should prompt me to create virtual directories but I am not getting prompted.
I installed VS2010 before installing IIS on my dev machine.
Here is my development machine setup:
Windows 7 Enterprise
Service Pack 1
64 bit OS
Visual Studio 2010 Enterprise Service pack 1
IIS version 7.5
Since the accepted answer requires IIS Manager, and IIS Express doesn't have IIS Manager or any UI, here's the solution for you IIS Express users (and should work for everyone else too):
When you open Visual Studio and get the error message, right-click the project Solution Explorer and choose "Edit {ProjectName}.csproj"
In the project file, change the following line:
<UseIIS>True</UseIIS>
to
<UseIIS>False</UseIIS>
Save the file.
Now reload your project.
Done.
You'll then be able to open your project. If at this point, you want to use IIS, simply go to your project properties, click the "Web" tab, and select the option to use IIS. There's the button there to "Create Virtual Directory". It may tell you that you need to run Visual Studio as an administrator to create that directory, so do that if needed.
Open the project folder and delete {Project}.csproj.user, then reload the project on Visual Studio.
When this happens the easiest solution is to make the virtual directory manually.
First of all, you need to make sure you have the right version of ASP.Net installed and that you have installed the IIS extensions.
To do this, go to the relevant .net version's folder in C:\(Windows)\Microsoft.NET\Framework\(dotnetver)\
(substituting the bracketed folders for the right folders on your PC) and run this command
aspnet_regiis.exe -i
Next once that's run and finished, sometimes running
iisreset
from the command line helps, sometimes you don't need to.
Next, go to your IIS Manager and find you localhost website and choose add a folder.
Browse to the folder in your project that contains the actual ASP.Net project and add that.
Finally, right click on the folder you added and you should have an option that says 'convert to application' or 'create virtual directory' or something similar.
!!Make sure the Virtual directory has the name 'MyWebApp'!!
Reload your solution and it should work.
Please be wary; this isn't a programming question (and shouldn't really be posted here) but I've posted this guidance as it's a common problem, but the advice I've posted is generic; the commands I've listed are correct but the steps you need to do in IIS may vary, it depends on your version and your account privileges.
Good luck!
This solution worked for me: Right click the Project and select edit and find the following code as shown below in the picture.
change the <UseIIS>True</UseIIS> to <UseIIS>False</UseIIS>
OR
change the <IISUrl>http://example.com/</IISUrl> to <IISUrl>http://localhost/</IISUrl>
For my project, I had to delete these two lines from .csproj file
<ProjectGuid>{3AA499DF-4A65-43B7-8965-D08A4C811834}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
I tried deleting only the first one, but it wasn't enough.
EDIT: As many users have pointed out, this can change your project type or mess with your source control program. I can't investigate these issues as it was a school project I do not have anymore.
Please be careful when trying this. At least make a copy of what you delete.
Edit the .csproj or vbproj file. Find and replace these entries
<UseIIS>true</UseIIS> by <UseIIS>false</UseIIS>
<UseIISExpress>true</UseIISExpress> by <UseIISExpress>false</UseIISExpress>
In my case, this problem was caused by broken IIS bindings. Specifically, my 'http' binding had been deleted. Recreating it fixed the problem.
Cause: The IISURL inside project.csproj is not correctly reflected in the project setting, and the virtual directory was not created.
Solution: Change the Project URL to correct PORT and create the Virtual Directory to make the missing PORT available.
Follow Below Steps:
Step 1: Right click on the project file to Edit the project.csproj file.
Step 2: Search IIS and modify from <UseIIS>True</UseIIS> to <UseIIS>False</UseIIS>
Step 3: Right Click Project to Reload the Project. After Reload successfully, right click Project and select Properties.
Step 4: Locate Project URL option under Properties => Web
Step 5: Change the Project URL to IIS URL indicated both on the Error Message and on the <IISURL>http://localhost:8086 </IISURL> from project.csproj file. Then Click Create Virtual Directory. Save All
Step 6: Redo Step 2 so it doesn't impact the remote codebase and the server deployment settings.
This worked for me:-
Make all your IIS websites point to localhost(All Unassigned) only
Try opening Visual Studio with Administrator privileges. In my case, it gave access to the IIS site and made this error go away. I was then able to switch the project to use IIS Express which doesn't seem to need administrator privileges.
If you are connected via TFS, open your project.csproj.user file and check for
<UseIISExpress>false</UseIISExpress>
and change it to true.
<UseIISExpress>true</UseIISExpress>
You will not believe that, start visual studio as Administrator
as obvious from the message
The Web Server 'http://localhost/MyWebApp' could not be found.
could not be found because may it has no privileges to see it
so Just restart visual studio as Administrator
You can load the project without setting the value of attribute UseIIS to true.
Simply follow the below steps:
In the mywebproject.csproj file--
Delete the tag < IISUrl>http://localhost/MyWebApp/< /IISUrl> and save the file.
The application will automatically assign the default port to it.
In my case I wanted to switch from http to https, so I had deleted http from IIS. In my .csproj.user file found that I still had:
<IISUrl>http://localhost/</IISUrl>
So I changed it to:
<IISUrl>https://localhost/</IISUrl>
In my case I was able to open the solution in offline mode just running the command:
iisreset
For you Win8 users out there, if you follow the steps in the accepted answer, console spits out a message at you saying "thou shalt not use the command-line to execute this command" (paraphrasing). Instead, access the Programs & Features via Control Panel (or Windows + R > appwiz.cpl), click 'Turn Windows features on or off', and make sure you have the following installed:
Internet Information Services
> World Wide Web Services
> Application Development Features
> ASP.NET 4.5
This will check a bunch of other options as well. As soon as I installed these features, and ran VS2012 with elevated permissions, I was able to launch my app successfully.
This happens with me when I tried to open a project from the .csproj file, but I get over it by opening the project from VS:
File> Open> Web Site
and select the directory which include my project.
I had this error, too. I thought everything was setup correctly, but I found out that one thing was missing: The host name I used for my project was not (yet) resolvable.
Since my app determines the current client's name from the host name I used a host name like clientname.mysuperapp.local for development. When I added the development host name to my hosts file, the project was loadable again. Obviously, I had to this anyway, but I haven't thought that VS checks the host name before loading the project.
Check if IIS Express is installed. If IIS Express is missing, Visual Studio might discard the setting <UseIISExpress>false</UseIISExpress> and still look for the express.
in my case, make sure you have a "Default" website
In my case, the "Default Web Site" in IIS didn't have a binding for localhost on port 80.
You should have a binding for whatever your value in the .csproj file is.
I fixed this simply by reinstalling IIS Express after downloading from below link:
https://www.microsoft.com/en-us/download/confirmation.aspx?id=48264
Turns out my IIS was working on localhost:8181.Had to configure the {Project}.csproj file.
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>7386</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>**http://localhost:8181/ProjectName**</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile><EnableWcfTestClientForSVCDefaultValue>True</EnableWcfTestClientForSVCDefaultValue>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
In my case, the url referenced in the csproj file was incorrect.
It needed to be prefixed with www.
I made the changes, saved the file and the project loaded fine.
I ran into this issue when the <ProjectTypeGuids> element in the .csproj file contained the unit test project GUID: {3AC096D0-A1C2-E12C-1390-A8335801FDAB}.
Removing it made the project load without problems.
For DNN users my issue was I needed a binding for dnndev.me at port 80. I have multiple installs that run on different ports and VS requires that that particular Url to exist on port 80 (not 86 like mine was).
Follow this completed solution step by step. it's works for me in VS 2017.
Open Command prompt in administrator mode
Open File explorer and got to .NET Framework folder
Eg:C:\Windows\Microsoft.NET\Framework\v4.0.30319
v4.0.30319 this is my .NET folder. you want to select your relevant folder.
in CMD - Go to .NET folder path
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
Execute below command in CMD
aspnet_regiis.exe -i
You can see this message finally - Finished installing ASP.NET (4.0.30319.0)
iisreset
You can see this message finally - Internet services successfully restarted
Open IIS in your computer (if not config Follow this)
Go to Site and right click
Add WebSite
Fill - Site name and select physical path
Then type port number (you can find port number in .csproj file and port number must equal with (IISUrl)
EG : <IISUrl>http://localhost:15724/</IISUrl> my port is 15724
Note : you cannot create port 80 number. because it used default IIS page
Click Ok
Open visual studio with administrator permission
Then right click and reload your project
Your Problem may be solved.
This may help some people in 2020. The main issue is that the IIS settings in the CSPROJ file don't match with the configuration for the machine. For example, if you had the Web Application Project pointing to localhost:12345, and a virtual directory isn't set up on the machine on that port, you'll get this error.
Using VS2019, I had this same issue, and the IIS settings in the CSProj file were being ignored. The reason for this is a new property in the CSProj file called "SaveServerSettingsInUserFile":
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<SaveServerSettingsInUserFile>True</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<UserProperties UseAjaxifiedTemplates="True" UseJQuerySupport="True" />
</VisualStudio>
</ProjectExtensions>
When this is set to TRUE, the IIS/Web server properties are in the
.CSPROJ.User file of the same project name.
This allows individual users of a project to have their own IIS settings, provided this file is not checked into source control.
You can control where the settings are stored using Visual Studio GUI in the properties for the project under "Web", "Apply server settings to all users"
When this is on, the IIS settings are stored in CSPROJ, when off, they are stored in CSPROJ.User

Visual Studio 'Publish' command fails

I'm working on a moderately sized WebForms project. Due to the peculiarities of management here, I have to upload the site to a remote server in order to test (no localhost testing). I'm using the 'Publish' command in Visual Studio 2008. Sometimes, it even works. Most of the time, I inexplicably get a "publish failed" in the bottom left corner, with no further details.
The few googled articles/forum posts I read suggested making the target local folder for the publish operation readable/writable for everyone. Doesn't help.
Is there are way to get further details as to WHY a publish fails in VS2008, and if not, is there a better way of doing these deployments? I'm spending more time building/pushing to the web server than actually debugging.
It's worth checking the output window. I've just had a publish fail because I had deleted an image outside of VS so VS was complaining that the image couldn't be found, but this information was only displayed in the output window.
See this link for more information:
http://ericfickes.com/2009/08/find-out-why-visual-studios-publish-fails/
It happens to us when there is an error in markup (!). Bad thing is that VS will just swallow the error and just tell you Failed.
What I suggest is to run your publish from command line using MSBuild. It's not that straightforward but it works (once you get into it).
I've since discovered that the reason for these particular publish failures was due the "Delete Existing Files" option being checked. Using Visual Studio 2008 under a non-administrative account on Windows Vista could cause a permissions error while attempting to delete the existing files. The publish would fail silently after encountering a file that Visual Studio had insufficient access to delete. Once the files were deleted manually outside of Vidual Studio, the publish functioned normally.
I have not had this issue with Windows 7; I assume the UAC changes in Windows 7 fixed the problem.
I mostly work with Web Forms, and I encounter this problem daily.
It seems to me that publish fails when it fails to delete a file it is trying to replace. Even if I don't have any files open, it still fails sometimes. Not sure why.
Not only VS publish fails very often, it is painfully slow as well.
I just publish to empty local directory and use separate FTP client to upload files. It's more work, but works.
This is probably not the case for you, but I've seen this happen when I'm publishing a web site. If the app_offline.htm file is not excluded from your project (if you use this file), the publish will fail.
Same happened to me.. what I did was include images files that was not included in the project and delete images that were not used.
After struggling with a similar issue for about 30 mins with no clue as to what was causing it closed down VS and reopened my project. Started working fine. No idea why but it worked.
You should always stop the IIS instance running on the machine your are publishing to. Google the word "iisreset". Other hosting providers like DiscountAsp and Arvixe offer you tools to "Stop" and "Start" your app pool on their IIS remotely. This is very necessary because IIS may have locked some files as "in use", so your publish fails when it tries to write over them. When your publish is complete, then just restart IIS (or press "Start" from a web tool if you're using a 3rd party hosting provider).
When all else fails, check your "Output" window (the tab to the right of your "Error List" at the bottom of Visual Studio). Scroll through all of it after a failed publish and look for anything that says "Unable to add". If you keep seeing the same "Unable to add" errors on the same publish, then ftp into the folder, delete the the problematic files manually, and try publishing again.
I got this when my ProjectName.Publish.xml file was read-only. Once I checked the file out of source control, I no longer got the error and could publish.
Just to add to this thread, I found that, for some bizarre reason, only the Mercurial files were being published to the server, everything else just wasn't being copied across.
Another strange thing was that only the Debug configuration was available; Release was nowhere to be seen.
After reading other threads around S.O., I found that there were many for VS 2010 and 2012, but not much to cover the same problem with 2008.
The fix, I found, was to delete the [solution].suo file and then attempt a publish. That seemed to do the job, though it took a long time to complete.
What I found and work in my case. It is to use a different version of VS.
I recently had the problem, the solution works perfectly in VS2015 build, compile and tested.
However, when I try to publish was failing silently.
So, I closed the solution and open it with VS2017 that use the same file structure for the projects/solutions. Then rebuild it and publish without any problems.
I believe it could be VS related and it is complicated to debug.
This is a workaround if you work with multiple Vs instances in your local machine.

Categories