C# Web 应用程序项目 [...] 被配置为使用 IIS。找不到 Web 服务器 [...]。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10889421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 15:39:35  来源:igfitidea点击:

The Web Application Project [...] is configured to use IIS. The Web server [...] could not be found.

c#asp.netiis

提问by dotnet-practitioner

I have a web project in my solution file that is "unavailable" when I open the solution. When I right-click on the web project and reload the project, I get the following error:

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

The Web Application Project mycompany.myapp.mywebproject is configured to use IIS. The Web Server 'http://localhost/MyWebApp could not be found.

The Web Application Project mycompany.myapp.mywebproject is configured to use IIS. The Web Server 'http://localhost/MyWebApp could not be found.

I have not manually set up virtual directories for this web application.

我没有为此 Web 应用程序手动设置虚拟目录。

Per colleagues, Visual Studio should prompt me to create virtual directories but I am not getting prompted.

对于同事,Visual Studio 应该提示我创建虚拟目录,但我没有收到提示。

I installed VS2010 before installing IIS on my dev machine.

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

Here is my development machine setup:

这是我的开发机器设置:

  • Windows 7 Enterprise
  • Service Pack 1
  • 64 bit OS
  • Visual Studio 2010 Enterprise Service pack 1
  • IIS version 7.5
  • Windows 7 企业版
  • 服务包 1
  • 64位操作系统
  • Visual Studio 2010 企业服务包 1
  • IIS 7.5 版

采纳答案by Russ Clarke

When this happens the easiest solution is to make the virtual directory manually.

发生这种情况时,最简单的解决方案是手动创建虚拟目录。

First of all, you need to make sure you have the right version of ASP.Net installed and that you have installed the IIS extensions.

首先,您需要确保安装了正确版本的 ASP.Net 并安装了 IIS 扩展。

To do this, go to the relevant .net version's folder in C:\(Windows)\Microsoft.NET\Framework\(dotnetver)\ (substituting the bracketed folders for the right folders on your PC) and run this command

为此,请转到 C:\(Windows)\Microsoft.NET\Framework\(dotnetver)\ 中相关 .net 版本的文件夹(用括号中的文件夹替换您 PC 上的正确文件夹)并运行此命令

aspnet_regiis.exe -i

Next once that's run and finished, sometimes running

接下来一旦运行并完成,有时会运行

iisreset

from the command line helps, sometimes you don't need to.

从命令行帮助,有时你不需要。

Next, go to your IIS Manager and find you localhost website and choose add a folder. Browse to the folder in your project that contains the actual ASP.Net project and add that.

接下来,转到您的 IIS 管理器并找到您的 localhost 网站并选择添加一个文件夹。浏览到项目中包含实际 ASP.Net 项目的文件夹并添加它。

Finally, right click on the folder you added and you should have an option that says 'convert to application' or 'create virtual directory' or something similar.

最后,右键单击您添加的文件夹,您应该有一个选项,显示“转换为应用程序”或“创建虚拟目录”或类似内容。

!!Make sure the Virtual directory has the name 'MyWebApp'!!

!!确保虚拟目录的名称为“MyWebApp”!!

Reload your solution and it should work.

重新加载您的解决方案,它应该可以工作。

Please be wary; this isn't a programming question (and shouldn't really be posted here) but I've posted this guidance as it's a common problem, but the advice I've posted is generic; the commands I've listed are correct but the steps you need to do in IIS may vary, it depends on your version and your account privileges.

请保持警惕;这不是一个编程问题(并且不应该真正发布在这里)但是我已经发布了这个指南,因为这是一个常见问题,但是我发布的建议是通用的;我列出的命令是正确的,但您需要在 IIS 中执行的步骤可能会有所不同,这取决于您的版本和您的帐户权限。

Good luck!

祝你好运!

回答by Doug S

Since the accepted answer requires IIS Manager, and IIS Express doesn't have IIS Manager or any UI, here's the solution for you IIS Express users (and should work for everyone else too):

由于接受的答案需要 IIS 管理器,而 IIS Express 没有 IIS 管理器或任何 UI,这里是 IIS Express 用户的解决方案(也应该适用于其他所有人):

When you open Visual Studio and get the error message, right-click the project Solution Explorer and choose "Edit {ProjectName}.csproj"

当您打开 Visual Studio 并收到错误消息时,右键单击项目解决方案资源管理器并选择“编辑 {ProjectName}.csproj”

In the project file, change the following line:
<UseIIS>True</UseIIS>
to
<UseIIS>False</UseIIS>
Save the file.

在项目文件中,更改以下行:
<UseIIS>True</UseIIS>

<UseIIS>False</UseIIS>
保存文件。

Now reload your project.
Done.

现在重新加载您的项目。
完毕。

You'll then be able to open your project. If at this point, you want to use IIS, simply go to your project properties, click the "Web" tab, and select the option to use IIS. There's the button there to "Create Virtual Directory". It may tell you that you need to run Visual Studio as an administrator to create that directory, so do that if needed.

然后,您将能够打开您的项目。如果此时您想使用 IIS,只需转到您的项目属性,单击“Web”选项卡,然后选择使用 IIS 的选项。那里有“创建虚拟目录”的按钮。它可能会告诉您需要以管理员身份运行 Visual Studio 才能创建该目录,因此请根据需要执行此操作。

回答by Roger Lipscombe

In my case, this problem was caused by broken IIS bindings. Specifically, my 'http' binding had been deleted. Recreating it fixed the problem.

就我而言,此问题是由损坏的 IIS 绑定引起的。具体来说,我的“http”绑定已被删除。重新创建它解决了问题。

回答by Conrado Fonseca

In my case I was able to open the solution in offline mode just running the command:

就我而言,我只需运行以下命令即可在离线模式下打开解决方案:

iisreset

回答by fero

I had this error, too. I thought everything was setup correctly, but I found out that one thing was missing: The host name I used for my project was not (yet) resolvable.

我也有这个错误。我认为一切都设置正确,但我发现缺少一件事:我用于项目的主机名(还)不可解析。

Since my app determines the current client's name from the host name I used a host name like clientname.mysuperapp.localfor development. When I added the development host name to my hostsfile, the project was loadable again. Obviously, I had to this anyway, but I haven't thought that VS checks the host name before loading the project.

由于我的应用程序根据主机名确定当前客户端的名称,因此我使用了一个类似于clientname.mysuperapp.local开发的主机名。当我将开发主机名添加到我的hosts文件时,该项目可以再次加载。显然,无论如何我都不得不这样做,但我没想到 VS 在加载项目之前会检查主机名。

回答by jcmordan

Edit the .csproj or vbproj file. Find and replace these entries

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

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

回答by Scott Silvi

For you Win8 users out there, if you follow the steps in the accepted answer, console spits out a message at you saying "thou shalt not use the command-line to execute this command" (paraphrasing). Instead, access the Programs & Features via Control Panel (or Windows + R > appwiz.cpl), click 'Turn Windows features on or off', and make sure you have the following installed:

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

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

This will check a bunch of other options as well. As soon as I installed these features, and ran VS2012 with elevated permissions, I was able to launch my app successfully.

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

回答by kad81

Try opening Visual Studio with Administrator privileges. In my case, it gave access to the IIS site and made this error go away. I was then able to switch the project to use IIS Express which doesn't seem to need administrator privileges.

尝试使用管理员权限打开 Visual Studio。就我而言,它允许访问 IIS 站点并使此错误消失。然后我能够将项目切换为使用 IIS Express,这似乎不需要管理员权限。

回答by qjuanp

Open the project folder and delete {Project}.csproj.user, then reload the project on Visual Studio.

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

回答by Thea

Check if IIS Express is installed. If IIS Express is missing, Visual Studio might discard the setting <UseIISExpress>false</UseIISExpress>and still look for the express.

检查是否安装了 IIS Express。如果缺少 IIS Express,Visual Studio 可能会放弃该设置<UseIISExpress>false</UseIISExpress>并仍在寻找 Express。