IIS Express unable to create the virtual directory

2019-01-30 17:23发布

I'm using IIS Express to create a virtual directory at http://localhost:5000/ and received this error:

Unable to create the virtual directory. The URL http://localhost:5000/ is already mapped to a different folder...

This is because I've used the port 5000 for an old project before and it's no longer needed.

My question is, how can I remove the old mapping using IIS Express so I can create the virtual directory at the same port again?

Thanks

标签: iis-express
4条回答
爷、活的狠高调
2楼-- · 2019-01-30 18:06

Seems you need to run Visual Studio with administrative rights if you want to create Virtual directory on ports below 1024.

查看更多
家丑人穷心不美
3楼-- · 2019-01-30 18:14

I was getting this because I had a site on the IIS Server (not express) with the same bindings (domain name and port) as IIS Express was trying to use.

I thought that since the site was not started it would ignore it, but I was wrong. Once I change it in IIS, then the IIS Express one worked and the error went away.

查看更多
老娘就宠你
4楼-- · 2019-01-30 18:15

No software installation required. Simply follow the steps:

Right-click the project node in the solution explorer and select the option to edit the project (.csproj) file. Near the bottom of the file, find the following:

<iisurl></iisurl>

Edit this entry to add your virtual directory:

<iisurl>http://localhost:5000/</iisurl>

查看更多
聊天终结者
5楼-- · 2019-01-30 18:24

You should be able to accomplish this in one of two ways.

  • You can remove the old project, or change its port using WebMatrix, which has an administration interface for IIS Express.
  • You can also do it by hand, by modifying the applicationhost.config file directly. The file is located in the %userprofile%\documents\IISexpress\config folder. You can find the project configuration under the <system.applicationHost>/<sites> element.

UPDATE: WebMatrix has been discontinued and support has officially ended.

查看更多
登录 后发表回答