简体   繁体   English

如何在Visual Studio 2012中重命名IIS Express网站

[英]How to rename an IIS Express website in Visual Studio 2012

I initially created a site in Webmatrix 2. I just called it website1. 我最初在Webmatrix 2中创建了一个站点。我刚才称它为website1。 I've now been working on the site in Visual Studio 2012 and I would like to rename it. 我现在一直在Visual Studio 2012中的网站上工作,我想重命名它。 It doesn't appear you can rename it directly, but in the .sln file there is a project entry which contains the string "website1". 它似乎不能直接重命名,但在.sln文件中有一个包含字符串“website1”的项目条目。 I renamed it and re-started VS. 我将其重命名并重新启动VS. The new name briefly displays but then gets overwritten with the original name. 新名称会暂时显示,但会被原始名称覆盖。 So now I have the .sln file with the new name and nowhere within the folders does it reference the old name - i've searched every file. 所以现在我有了新名称的.sln文件,文件夹中没有任何地方引用旧名称 - 我搜索过每个文件。 But yet VS insists on calling the site website1. 但是VS坚持要求调用网站1。 So i'm totally confused. 所以我完全糊涂了。

Any ideas where VS stores the name of websites? VS存储网站名称的任何想法? The only thing I can come up with is how VS integrates with IIS Express. 我唯一能想到的是VS如何与IIS Express集成。 Perhaps it is taking the name from IIS instead? 也许它取而代之的是IIS的名字?

I just encounter the same problem with you during using VS 2013, it turned out that it's caused by IIS Express, finally I solved it by following steps: 我在使用VS 2013时遇到了同样的问题,结果发现它是由IIS Express引起的,最后我通过以下步骤解决了这个问题:

  1. Find the applicationhost.cofig of your IIS Express, usually it should be listed in Folder C:\\Users{username}\\Documents\\IISExpress\\config 找到IIS Express的applicationhost.cofig,通常它应该列在文件夹C:\\ Users {username} \\ Documents \\ IISExpress \\ config中
  2. Locate the corresponding site section of your project in the cofig file 在cofig文件中找到项目的相应站点部分
  3. Remove all those site section with simillar site name like ProjectNameABC and ProjectNameABC(1) 删除所有那些使用simillar网站名称的网站部分,如ProjectNameABCProjectNameABC(1)
  4. Close and Reopen your solution in vs, you'll found that the spefic name for your web project come back 关闭并在vs中重新打开您的解决方案,您将发现您的Web项目的特定名称返回

I had the exact same problem, and after a lot of hair pulling realized that IIS Express (as you said) somehow was the culprit. 我有完全相同的问题,经过大量的头发拉动意识到IIS Express(如你所说)不知何故是罪魁祸首。 However, I couldn't find out where the site name was stored. 但是,我找不到网站名称的存储位置。

This is what I ended up doing (in addition to renaming directories and replacing the old project name with the new one in the solution file): 这就是我最终做的事情(除了重命名目录并用解决方案文件中的新项目替换旧项目名称):

  • Open up the .sln file 打开.sln文件
  • Locate the Project entry for the web site you want to rename 找到要重命名的网站的“ Project条目
  • Change the port of the URL. 更改URL的端口。 This will force IIS Express to treat it as a new site. 这将强制IIS Express将其视为新站点。

Hope this helps someone! 希望这有助于某人!

I had the same problem for HTTPS and Visual Studio 2015 . 我对HTTPSVisual Studio 2015也有同样的问题。

The IIS Express configuration file "C:\\Users{username}\\Documents\\IISExpress\\config\\applicationhost.config" didn´t have the reference for my site. IIS Express配置文件“C:\\ Users {username} \\ Documents \\ IISExpress \\ config \\ applicationhost.config” 没有我的站点的参考。

I found the reference inside the solution directory in a hide directory 我在隐藏目录中找到了解决方案目录中的引用

"{Solution}\\.vs\\config\\applicationhost.config" “{解决方案} \\ VS \\设置\\对ApplicationHost.config”

I removed the entry for the old copy site, closed and reopen the project and everything was right. 我删除了旧拷贝站点的条目,关闭并重新打开项目,一切都正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IIS表示在visual studio 2012中无效 - IIS express not working in visual studio 2012 无法在Visual Studio 2012中显示.svg文件(IIS Express) - Cannot display .svg files in Visual Studio 2012 (IIS Express) 设置IIS Express以在Visual Studio 2012上接受本地连接 - Setting up IIS Express to accept local connections on visual studio 2012 在Visual Studio 2012中进行调试时将IIS Express更改为全功能IIS - Change IIS Express to full functions IIS when debug in Visual Studio 2012 如何在Visual Studio Express 2012 for Web中设置固定端口 - How to set fixed port in Visual Studio Express 2012 for Web Visual Studio 2012 Express:如何使用自定义 Web 服务器进行调试 - Visual Studio 2012 Express: How to Debug with Custom Webserver 在visual studio上使用IIS而不是IIS Express - using IIS instead of IIS Express on visual studio 从Visual Studio 2012将非MVC网站部署到IIS7(Windows 2008)服务器 - Deploying non-MVC website to IIS7 (Windows 2008) server from Visual Studio 2012 如何检查我的项目是Visual Studio 2012中的网站还是Web应用程序? - How to check if my project is a website or a webapp in Visual Studio 2012? 如何使用Visual Studio 2012创建.Net 2.0版网站? - How to create a .Net version 2.0 website using Visual Studio 2012?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM