remove virtual directory in IIS Express created in error
Solution 1
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>
Solution 2
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.
Solution 3
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
Solution 4
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.
Solution 5
You can use appcmd.exe in C:\program files (x86)\IISExpress
appcmd list vdir
should list the virtual directories and
appcmd delete vdir VDIR.NAME
to delete. Or, if you use Powershell, the commands start with .\
, e.g., .\appcmd list vdir
.
Related videos on Youtube
John
Updated on January 07, 2021Comments
-
John over 3 years
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?
-
messed-up almost 7 yearsI did this, but it keep creating the site every time i run the project.
-
BraveNewMath almost 7 yearsCheck the project settings, make sure the deploy setting doesn't specify the virtual path.
-
Matt Sanders over 6 yearsThanks! Removing competing bindings from different projects in VS 2017 (.vs directory) and rebooting fixed this for me
-
Jeremy McGee about 6 yearsIf using Visual Studio 2017 the configuration file might be hidden in a
.vs
folder that's not visible. -
Brisbe over 5 yearsCould you please add text descriptions of where to make these changes, as well as the images?
-
Jyotirmoy Pramanik over 5 yearsSure... I'll add the steps in the answer.
-
Torben Junker Kjær over 5 yearsI deleted the applicationhost.config file, restarted Visual Studio and it worked.
-
bluekushal over 4 yearsWorks in VS 2019 as well.
-
Stephen Byrne about 4 yearsThis 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!
-
Javier Contreras over 3 yearsI got rid of .vs folder and restart Visual Studio. Problem solved.
-
Meeting Attender about 3 yearsReboot was a must for me even though it doesn't make sense (why it's needed).
-
cah1r about 2 yearsthis 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