当我打开解决方案时,我的解决方案文件中有一个“不可用”的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版


当前回答

检查是否安装了IIS Express。如果IISExpress丢失,Visual Studio可能会丢弃设置<UseIISExpress>false</UseIISExpress>,并且仍然寻找该Express。

其他回答

你不会相信,以管理员身份启动visual studio

从信息中可以明显看出

无法找到Web服务器“http://localhost/MyWebApp”。

无法找到,因为可能它没有看到它的特权

所以只要重新启动visual studio作为管理员

对于Win8用户来说,如果你按照已接受的答案中的步骤操作,控制台会向你发出一条消息,告诉你“你不应该使用命令行来执行这个命令”(释义)。相反,通过控制面板(或Windows + R > appwizc .cpl)访问程序和功能,单击“打开或关闭Windows功能”,并确保您安装了以下程序:

Internet Information Services
  > World Wide Web Services
    > Application Development Features
      > ASP.NET 4.5

这将检查一堆其他选项以及。一旦我安装了这些功能,并运行了具有更高权限的VS2012,我就能够成功启动我的应用程序。

当我试图从.csproj文件打开一个项目时,这发生在我身上,但我通过从VS打开项目来克服它:

文件>打开>网站

然后选择包含我的项目的目录。

原来我的IIS在localhost:8181上工作。必须配置{Project}。csproj文件。

    <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>True</UseIIS>
          <AutoAssignPort>True</AutoAssignPort>
          <DevelopmentServerPort>7386</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>**http://localhost:8181/ProjectName**</IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl>
          </CustomServerUrl>
          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile><EnableWcfTestClientForSVCDefaultValue>True</EnableWcfTestClientForSVCDefaultValue>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>

遵循这个完整的解决方案一步一步。这在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

你的问题可能会解决。