当我打开解决方案时,我的解决方案文件中有一个“不可用”的web项目。当我右键单击web项目并重新加载项目时,我得到以下错误:

Web应用程序项目mycompany.myapp.mywebproject已配置为使用IIS。无法找到Web服务器http://localhost/MyWebApp。

我还没有为这个web应用程序手动设置虚拟目录。

每个同事,Visual Studio应该提示我创建虚拟目录,但我没有得到提示。

在我的开发机器上安装IIS之前,我安装了VS2010。

这是我的开发机器设置:

Windows 7企业版 服务包1 64位操作系统 Visual Studio 2010企业服务包 IIS 7.5版


当前回答

打开项目文件夹,删除{project}.csproj。用户,然后在Visual Studio上重新加载项目。

其他回答

在我的情况下,我想从http切换到https,所以我已经从IIS删除了http。在我的。csproj。用户文件发现我仍然有:

<IISUrl>http://localhost/</IISUrl>

所以我把它改成:

<IISUrl>https://localhost/</IISUrl>

尝试使用管理员权限打开Visual Studio。在我的例子中,它提供了对IIS站点的访问,并使这个错误消失了。然后,我可以将项目切换到使用IIS Express,这似乎不需要管理员特权。

遵循这个完整的解决方案一步一步。这在VS 2017中很适用。

Open Command prompt in administrator mode Open File explorer and got to .NET Framework folder Eg:C:\Windows\Microsoft.NET\Framework\v4.0.30319 v4.0.30319 this is my .NET folder. you want to select your relevant folder. in CMD - Go to .NET folder path cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 Execute below command in CMD aspnet_regiis.exe -i You can see this message finally - Finished installing ASP.NET (4.0.30319.0) iisreset You can see this message finally - Internet services successfully restarted Open IIS in your computer (if not config Follow this) Go to Site and right click Add WebSite Fill - Site name and select physical path Then type port number (you can find port number in .csproj file and port number must equal with (IISUrl) EG : <IISUrl>http://localhost:15724/</IISUrl> my port is 15724 Note : you cannot create port 80 number. because it used default IIS page Click Ok Open visual studio with administrator permission Then right click and reload your project

你的问题可能会解决。

这个解决方案对我来说很有效:右键单击项目并选择编辑并找到如下图所示的以下代码。

将<UseIIS>True</UseIIS>修改为<UseIIS>False</UseIIS>

OR

更改<IISUrl>http://example.com/</IISUrl> < lisurl >http://localhost/</ lisurl >

编辑.csproj或vbproj文件。找到并替换这些条目

<UseIIS>true</UseIIS> by <UseIIS>false</UseIIS>
<UseIISExpress>true</UseIISExpress> by <UseIISExpress>false</UseIISExpress>