asp.net-mvc 在 VS2010 中将端口 80 与 IIS Express 一起使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5671205/
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
Using port 80 with IIS Express inside of VS2010
提问by Nick Albrecht
I've got an app that I am trying to run on my dev system under IIS Express from VS2010 that I need to use port 80 for, but I can't get it to work. I've looking up information talking about port 80 being reserved. http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/
我有一个应用程序,我试图在 VS2010 的 IIS Express 下在我的开发系统上运行,我需要使用端口 80,但我无法让它工作。我正在查找有关保留端口 80 的信息。 http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/
But even after doing that I still get an error from vs2010 that says "Unable to launch the IIS Express Web server. Port '80' is in use."
但即使这样做之后,我仍然收到来自 vs2010 的错误消息,提示 “无法启动 IIS Express Web 服务器。端口 '80' 正在使用中。”
I don't know what else to try. I've used Process Hacker to track down port 80 and it seems to be used by System
running on process ID 4, which is the NT Kernel and System process. I don't know if that would prevent me from using the port though. I thought maybe that was a result of http.sys holding that port so nothing else could use it?
我不知道还能尝试什么。我已经使用 Process Hacker 来追踪端口 80,它似乎是通过System
在进程 ID 4 上运行来使用的,它是 NT 内核和系统进程。我不知道这是否会阻止我使用该端口。我想这可能是 http.sys 持有该端口的结果,所以没有其他人可以使用它?
I did managed to get IIS Express to run on port 80 by modifying the default binding of the C:\Users\[MyUser]\Documents\IISExpress\config\applicationhost.config
file, and while I can start IIS Express manually this way, VS then gets an error because a binding already exists on that port. So I change it back to 8080, create the virtual directory using the button within VS2010 (which I'm guessing is the same as entering a site binding) but I still get an error when I go to debug the application. Is there something hardcoded in VS2010 that won't let it start IIS Express on port 80?
我确实通过修改C:\Users\[MyUser]\Documents\IISExpress\config\applicationhost.config
文件的默认绑定设法让 IIS Express 在端口 80 上运行,虽然我可以通过这种方式手动启动 IIS Express,但 VS 会收到错误,因为该端口上已经存在绑定。所以我把它改回 8080,使用 VS2010 中的按钮创建虚拟目录(我猜这与输入站点绑定是一样的)但是当我去调试应用程序时仍然出现错误。在 VS2010 中是否有一些硬编码的东西不会让它在端口 80 上启动 IIS Express?
UPDATE & FIX:Ok, so I found a few more things to check and I did resolve my problem but not completely. One post suggested making sure I did not have SQL reporting services installed as it can monitor on port 80, I used to have it installed but not anymore and was not the problem I was encountering. I did however realize that I have WebDeploy installed. It was bundled with the VS2010 SP1 bundle from the Web Platform Installer. This is fine as I do want the client tools from WebDeploy, but it also installed the agent on my system which was monitoring on port 80. I went to my list of services and stopped the Web Deploy Agent Service
. Soon as I did this I can now use port 80 for IIS Express from within VS2010.
更新和修复:好的,所以我发现了更多要检查的东西,我确实解决了我的问题,但并没有完全解决。一篇文章建议确保我没有安装 SQL 报告服务,因为它可以在端口 80 上进行监控,我曾经安装过它,但现在没有了,这不是我遇到的问题。然而,我确实意识到我已经安装了 WebDeploy。它与来自Web Platform Installer的 VS2010 SP1 捆绑包捆绑在一起。这很好,因为我确实需要来自 WebDeploy 的客户端工具,但它也在我的系统上安装了代理,该代理在端口 80 上进行监控。我转到我的服务列表并停止了Web Deploy Agent Service
. 完成此操作后,我现在可以在 VS2010 中为 IIS Express 使用端口 80。
New Issue related to running on port 80 in IIS ExpressHowever my application is an MVC3 App, and I've run into a problem because the MVC3 isn't capturing my request at all, so It's not firing my controller actions or anything like that, but a txt file in the root of my app can be reached so I know it's my site that IIS Express is serving up. Anyone have any issues running an MVC3 (I don't know if it's exclusive to MVC3 or not) in IIS Express on port 80?
与在 IIS Express 中的端口 80 上运行相关的新问题但是我的应用程序是一个 MVC3 应用程序,我遇到了一个问题,因为 MVC3 根本没有捕获我的请求,所以它没有触发我的控制器操作或类似的操作,但是可以访问我的应用程序根目录中的 txt 文件,因此我知道 IIS Express 正在提供我的站点。在 80 端口上的 IIS Express 中运行 MVC3(我不知道它是否是 MVC3 独有的)有任何问题吗?
采纳答案by Nick Albrecht
Just posting my own answer for this problem so I can mark the question as answered. Check http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/Disable the Web Deploy Agent service if you have it installed.
只需发布我自己对此问题的答案,以便我可以将问题标记为已回答。检查http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/如果已安装,请禁用 Web 部署代理服务。
回答by Nour Sammour
in my case i solved the issue by stop "SQL Server Reporting Services"
就我而言,我通过停止“SQL Server Reporting Services”解决了这个问题
you can find it in
你可以在
control panel -> sevices
控制面板 -> 服务
回答by Kendall Bennett
THANK YOU very much for you discovering of the 'Web Deploy Agent' service! This is something that only recently got turned on as I had all this working perfectly and just today installed the updated version of IIS Express, and ran into the exact same problem with port 80. So now that I have turned off the Web Deploy agent, my system works correctly again.
非常感谢您发现“Web 部署代理”服务!这是最近才启用的,因为我所有这些都运行良好,今天刚刚安装了 IIS Express 的更新版本,并且在端口 80 上遇到了完全相同的问题。所以现在我已经关闭了 Web 部署代理,我的系统再次正常工作。
As for ASP.NET MVC3, that works great for me on port 80 and port 443. It was quite a bit of work to bind both those ports so that IIS Express was able to use them as a normal user (most of it from the link you posted above), and to install the SSL certificate we use. I manually created all the entries in my applicationhost.config file to get this working, and the appropriate sites section is below:
至于 ASP.NET MVC3,它在端口 80 和端口 443 上对我来说非常有用。绑定这两个端口需要大量的工作,以便 IIS Express 能够以普通用户的身份使用它们(其中大部分来自您在上面发布的链接),并安装我们使用的 SSL 证书。我在 applicationhost.config 文件中手动创建了所有条目以使其正常工作,相应的站点部分如下:
<sites>
<site name="PHP: A Main" id="2144116512">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\var\www\amain\www" />
<virtualDirectory path="/images" physicalPath="C:\var\www\images" />
</application>
<application path="/admin">
<virtualDirectory path="/" physicalPath="C:\var\www\amain\www\admin" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:test.amainhobbies.com" />
<binding protocol="https" bindingInformation="*:443:test.amainhobbies.com" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
Note that my site is a combined PHP and ASP.NET MVC3 site, as we are in the process of re-writing the entire thing to run on ASP.NET MVC3, so most of the site is still PHP but lots of new stuff is now running ASP.NET MVC3, and that stuff works for me.
请注意,我的站点是 PHP 和 ASP.NET MVC3 的组合站点,因为我们正在重新编写整个内容以在 ASP.NET MVC3 上运行,所以大部分站点仍然是 PHP,但许多新内容是现在运行 ASP.NET MVC3,这些东西对我有用。
Does your IIS Express work properly with MVC3 outside of Visual Studio, or is the MVC3 stuff just not working at all?
您的 IIS Express 是否在 Visual Studio 之外与 MVC3 一起正常工作,或者 MVC3 的东西根本不起作用?
回答by Bikey
I didn't have the Web Deploy Agent installed but ran into this issue. You can also fix this by running this command to find out which application or service is using the port and then trace it down in Task manager.
我没有安装 Web 部署代理,但遇到了这个问题。您还可以通过运行此命令来找出哪个应用程序或服务正在使用该端口来解决此问题,然后在任务管理器中对其进行跟踪。
netstat -o -n -a | findstr 0.0:80
netstat -o -n -a | findstr 0.0:80
Then open Task manager, go to Processes, click the checkbox "Show processes for all users" and then click the View menu and Go to the Columns, add the PID column.
然后打开任务管理器,转到进程,单击复选框“为所有用户显示进程”,然后单击查看菜单并转到列,添加 PID 列。
Match the Process ID from the netstat command to the PID in task manager and you will find the service or application that's using the port.
将 netstat 命令中的进程 ID 与任务管理器中的 PID 匹配,您将找到使用该端口的服务或应用程序。
回答by Aliaksandr Naidzenka
That solution helped me.
该解决方案帮助了我。
On Windows 7 or Windows Vista, from an elevated command prompt, run the following command: console
在 Windows 7 或 Windows Vista 上,从提升的命令提示符运行以下命令:console
netsh http add urlacl url=http://localhost:80/ user=everyone
This command will allow any user's application (including your own IIS Express instances) to run using port 80 without requiring administrative privileges. To limit this access to yourself, replace "everyone" with your Windows identity.
此命令将允许任何用户的应用程序(包括您自己的 IIS Express 实例)使用端口 80 运行,而无需管理权限。要将此访问权限限制为您自己,请将“所有人”替换为您的 Windows 身份。
Taken from that source -> https://docs.microsoft.com/en-us/iis/extensions/using-iis-express/handling-url-binding-failures-in-iis-express