remove virtual directory in IIS Express created in error

26,194

Solution 1

enter image description here

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.config
and 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.

Share:
26,194

Related videos on Youtube

John
Author by

John

Updated on January 07, 2021

Comments

  • John
    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
    messed-up almost 7 years
    I did this, but it keep creating the site every time i run the project.
  • BraveNewMath
    BraveNewMath almost 7 years
    Check the project settings, make sure the deploy setting doesn't specify the virtual path.
  • Matt Sanders
    Matt Sanders over 6 years
    Thanks! Removing competing bindings from different projects in VS 2017 (.vs directory) and rebooting fixed this for me
  • Jeremy McGee
    Jeremy McGee about 6 years
    If using Visual Studio 2017 the configuration file might be hidden in a .vs folder that's not visible.
  • Brisbe
    Brisbe over 5 years
    Could you please add text descriptions of where to make these changes, as well as the images?
  • Jyotirmoy Pramanik
    Jyotirmoy Pramanik over 5 years
    Sure... I'll add the steps in the answer.
  • Torben Junker Kjær
    Torben Junker Kjær over 5 years
    I deleted the applicationhost.config file, restarted Visual Studio and it worked.
  • bluekushal
    bluekushal over 4 years
    Works in VS 2019 as well.
  • Stephen Byrne
    Stephen Byrne about 4 years
    This 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
    Javier Contreras over 3 years
    I got rid of .vs folder and restart Visual Studio. Problem solved.
  • Meeting Attender
    Meeting Attender about 3 years
    Reboot was a must for me even though it doesn't make sense (why it's needed).
  • cah1r
    cah1r about 2 years
    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