asp.net-mvc 无法使用 IIS Express 在 Windows 10 上运行 Web 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31959548/
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-09-07 23:28:52  来源:igfitidea点击:

Cannot run web application on Windows 10 using IIS Express

asp.net-mvcvisual-studio-2013windows-10iis-express

提问by Matze

I am developing a web application using ASP.NET MVC (a rather simple application, having just a single controller and a few routes; there′s nothing fancy in it). In the beginning I used Visual Studio 2013 and Windows 8/8.1. A couple of days ago I switched to Windows 10 and I am having trouble to run the application on my local development machine (I have both Visual Studio 2013 and 2015 installed, but I continue using Visual Studio 2013 for this project).

我正在使用 ASP.NET MVC 开发一个 web 应用程序(一个相当简单的应用程序,只有一个控制器和几个路由;里面没有什么花哨的东西)。一开始我使用 Visual Studio 2013 和 Windows 8/8.1。几天前,我切换到 Windows 10,但无法在本地开发机器上运行该应用程序(我安装了 Visual Studio 2013 和 2015,但我继续使用 Visual Studio 2013 进行此项目)。

When I start a new instance for debugging, IIS Express starts, Visual Studio launches the selected browser (which is Edge by default), but the request to the site never returns a valid response.

当我启动一个新的调试实例时,IIS Express 启动,Visual Studio 启动选定的浏览器(默认为 Edge),但对站点的请求永远不会返回有效响应。

I can see in the system tray, that the application seems to be running fine. I also checked with Fiddler; and Fiddler shows me that the browser′s request never gets a response from the local server. Can this be an issue with the firewall?

我可以在系统托盘中看到,该应用程序似乎运行良好。我还检查了 Fiddler;Fiddler 向我展示了浏览器的请求永远不会从本地服务器得到响应。这可能是防火墙的问题吗?

Update

更新

I think it has nothing to do with the Edge-browser nor with the localhost loopbacksetting (this setting has been enabled via about:flagspage). Furthermore, I experience this problem under the final version of Windows 10.

我认为这与 Edge 浏览器和localhost loopback设置无关(此设置已通过about:flags页面启用)。此外,我在 Windows 10 的最终版本下遇到了这个问题。

回答by DJH2006X

I got it working for me, uninstall IIS Express 10.0 from 'Programs and Features' and install IIS Express 8.0. I have no idea what caused the issue in v10.0 as it works on some of my office machines and not on others (all Windows 10 x64).

我让它对我来说有效,从“程序和功能”卸载 IIS Express 10.0 并安装 IIS Express 8.0。我不知道是什么导致了 v10.0 中的问题,因为它适用于我的某些办公计算机而不是其他计算机(所有 Windows 10 x64)。

回答by Alan Stark

(To moderators: please take the time to actually read my answer. It is not a 'thank you' post. It expands a hint that didn't work 'as-is' into a full solution)

对版主:请花时间实际阅读我的答案。这不是“谢谢”帖子。它将“原样”不起作用的提示扩展为完整的解决方案)

Solved it. First I tried:

解决了。首先我试过:

  • Reinstalling IIS Express 10
  • Installing IIS Express 8
  • Deleting applicationhost.config
  • 重新安装 IIS Express 10
  • 安装 IIS Express 8
  • 删除 applicationhost.config

Nothing helped. I started IIS Express 10 via the command line and it worked fine. But Visual studio wouldn't launch my project.

没有任何帮助。我通过命令行启动了 IIS Express 10,它运行良好。但是 Visual Studio 不会启动我的项目。

Then I realized that my project settings survived several Windows reinstalls and migration from Windows 8 to Windows 10. So I deleted the entire .vssolution folder. Voila! The ASP.NET MVC web application is running in IIS Express 10.

然后我意识到我的项目设置在几次 Windows 重新安装和从 Windows 8 迁移到 Windows 10 后仍然存在。所以我删除了整个.vs解决方案文件夹。瞧!ASP.NET MVC Web 应用程序在 IIS Express 10 中运行。

Credits go to @Bron Davies for mentioning the .vsfolder. Going down this path led me to a full solution.

感谢@Bron Davies 提及该.vs文件夹。沿着这条路走下去,我找到了一个完整的解决方案。

回答by Bron Davies

Try deleting your applicationhost.configfile in %USERPROFILE%\Documents\IISExpress\config- this file can be problematic after an upgrade from Windows 7/8. When you start your project again, it will be recreated.

尝试删除您的applicationhost.config文件%USERPROFILE%\Documents\IISExpress\config- 从 Windows 7/8 升级后,此文件可能会出现问题。当您再次启动您的项目时,它将被重新创建。

How can I create new applicationhost.config file in IIS Express Server?

如何在 IIS Express Server 中创建新的 applicationhost.config 文件?

Also, make sure you are using IIS Express 8 for VS 2013. VS 2015 uses IIS Express 10 which has a different config file location per solution located in .vs\config\

另外,请确保您使用的是 IIS Express 8 for VS 2013。VS 2015 使用 IIS Express 10,它的每个解决方案都有不同的配置文件位置 .vs\config\

Just as an aside, I highly recommend updating to VS 2015 if developing on Windows 10. The projects are still backward compatible if you have to switch back or collaborate with someone using 2013

顺便说一句,如果在 Windows 10 上开发,我强烈建议更新到 VS 2015。如果您必须切换回或与使用 2013 的人协作,这些项​​目仍然向后兼容

回答by Julien

I got the same issue as DJH2006X.

我遇到了与 DJH2006X 相同的问题。

I had to install IIS Express 8 instead of 10 and it works fine.

我必须安装 IIS Express 8 而不是 10,它运行良好。

回答by Leonardo

I just solved this problem... for some reason, win 10 was detecting my network connection as public... after setting it to private, and restarting IIS express everything worked fine... no need to run scripts or anything... (FYI, I had disabled win firewall ages ago...)

我刚刚解决了这个问题……出于某种原因,win 10 检测到我的网络连接为公共连接……将其设置为私有后,并重新启动 IIS 表示一切正常……无需运行脚本或任何东西…… (仅供参考,我很久以前就禁用了 win 防火墙......)

回答by Hiran

First thing is to delete applicationhost.configfrom the project folder ( as described above) and restart the visual studio. this will work for most of the scenarios.

首先是 从项目文件夹中删除applicationhost.config(如上所述)并重新启动 Visual Studio。这将适用于大多数情况。