I clicked on create virtual directory of the web tab of the properties menu. My application now isn't running (the published version is) It just hangs when any of my controllers code is executed I think I've messed up the IIS config Can anyone help me out?
7 Answers
My file was located here:
C:\Users\YourUserName\Documents\IISExpress\config\applicationhost.config
Entries will look like this
<application path="/virtualDirectoryName" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\projects\Project1" />
</application>

- 8,090
- 5
- 46
- 51
-
1I did this, but it keep creating the site every time i run the project. – messed-up Jun 28 '17 at 20:16
-
Check the project settings, make sure the deploy setting doesn't specify the virtual path. – BraveNewMath Jul 21 '17 at 16:09
-
1If using Visual Studio 2017 the configuration file might be _hidden_ in a `.vs` folder that's not visible. – Jeremy McGee Mar 02 '18 at 08:02
-
2I deleted the applicationhost.config file, restarted Visual Studio and it worked. – Torben Junker Kjær Nov 22 '18 at 13:10
-
I got rid of .vs folder and restart Visual Studio. Problem solved. – Javier Contreras Aug 19 '20 at 23:22
None of this worked for me - possibly because I'm working with a later version of the tools (VS 2017). I finally found the correct appplicationhost.config file in the .vs directory for the solution, edited it, rebooted, and it worked.

- 6,255
- 8
- 45
- 71
-
4Thanks! Removing competing bindings from different projects in VS 2017 (.vs directory) and rebooting fixed this for me – Matt Sanders Jan 10 '18 at 20:41
-
1
-
Reboot was a must for me even though it doesn't make sense (why it's needed). – Meeting Attender Mar 03 '21 at 01:32
If you created another virtual directory by mistake, go to your .vs folder inside your solution/project folder and look for a file called:
applicationhost.configand change/fix what is inside the tag:
<sites>
<site name="YourSite" id="1">
...
</site>
...
</sites>
Hope this helps! :D

- 191
- 1
- 6
I realize this has been answered a few times over, but had this exact same issue in VS 2019
so I performed the following steps:
- Closed the
Solution
- Navigated in the file system to the
.vs
folder within my solution and deleted it - Reopened
Solution
and rebuilt.
Upon reopening the solution and Starting
the project, it appeared to have worked without any sort of reboot.
Some may consider deleting the .vs
folder destructive in some way but given the fact it's normally excluded from most (if not all source control systems) there isn't really anything mission critical in there and it all gets rebuilt anyways.

- 1,329
- 15
- 12
-
1This just saved me after about an hour of frustration when IIS Express just suddenly decided to start serving old versions of my app during debugging, thanks! – Stephen Byrne Mar 29 '20 at 10:29
-
this helped a little but in the end i just cloned a fresh repo. All of the meta files that were corrupted just recreated fresh this way – cah1r Apr 25 '22 at 11:39
I faced the same issue today. The simplest way to deal with this is just simply change the Port number. Go to the Properties of the Project which you have made as Startup Project. Then...
Click to view => Step 1
Let's say the initial port number is 62168. Just increment it by 1.
Click to view => Step 2
And create a new virtual directory. Now execute the project again. This time it'll work.
Steps:
Go to Properties window of the project selected as the StartUp Project
Select the "Web" section present in the LHS of the Properties window
Go to the Servers part (which is present below the "Start Action" part )
In the Project URL section, increment the value of Port Number by 1 or 2 (modified Port number must be free) and click on "Create Virtual Directory"
Save the changes and run the application using CTRL+F5
Hope this helps!

- 41
- 3
-
Could you please add text descriptions of where to make these changes, as well as the images? – Brisbe Oct 05 '18 at 15:44
-
1
VS 2019 -
There are multiple places that the applicationhost.config
resides. Two of those should are where the virtual directory data is put.
First location:
C:\Users\YourUserName\Documents\IISExpress\config\applicationhost.config
Second location:
C:\YourPathToSolutionFolder\.vs\SolutionName\config\applicationhost.config.
** please note: in the .vs there are two folders one is the config folder and the other should be the name of your solution. Navigate into your solution named folder and you will find another config folder. Inside there is the applicationhost.config
file you need to edit.
In both files you will need to remove the following (I just search for virtualdirectory).
<application path="/virtualDirectoryName" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\projects\Project1" />
</application>
Hopefully you won't have to delete the entire .vs folder which is an option if needed.
Note: This combines two answer from above Diego Murakami and BraveNewMath

- 1,646
- 2
- 24
- 46
-
The second location was `C:\YourPathToSolutionFolder\.vs\SolutionName\config\applicationhost.config` for me. @ZombieCode, can you check if you missed the `config` part of the path? – GreenRaccoon23 Jul 27 '22 at 14:55
-
1You are correct. Thank you for catching that. I have fixed the post. – ZombieCode Aug 03 '22 at 07:02