C# 在 ASP.NET 中调试时,什么可能导致 LocalHost 上的“连接中断”

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

What could cause "Connection Interrupted" on LocalHost when debugging in ASP.NET

c#asp.netlocalhost

提问by Jeff Dalley

I'm trying to run a freshly created ASP.NET Website using C#, however when I do so it launches FireFox and attempts to connect to http://localhost:1295/WebSite1/Default.aspx(for example), but after about 10-15 seconds it displays a "Connection Interrupted - The connection to the server was reset while the page was loading." Error.

我正在尝试使用 C# 运行一个新创建的 ASP.NET 网站,但是当我这样做时它会启动 FireFox 并尝试连接到http://localhost:1295/WebSite1/Default.aspx(例如),但大约10-15 秒后,它会显示“连接中断 - 页面加载时与服务器的连接已重置”。错误。

This issue is also present with older ASP.NET C# pages/Web Services I've built in the past, nothing is actually running off the ASP.NET Development server.

这个问题也存在于我过去构建的较旧的 ASP.NET C# 页面/Web 服务中,实际上没有在 ASP.NET 开发服务器上运行。

I am using: Windows XP Pro SP2, Visual Studio 2008

我使用的是:Windows XP Pro SP2、Visual Studio 2008

For reference I have SQL Server 2005 Developer Edition installed as well.

作为参考,我也安装了 SQL Server 2005 Developer Edition。

I have tried:

我试过了:

  • Browsing it with IE instead of Mozilla
  • Trying 2.0 framework instead of 3.5
  • Reinstalling Visual Studio 2008
  • 使用 IE 而不是 Mozilla 浏览它
  • 尝试 2.0 框架而不是 3.5
  • 重新安装 Visual Studio 2008

This problem seems so trivial the more I think about it, but I havn't been able to work it out just yet! Appreciate any help on the matter.

这个问题越想越微不足道,但我还没能解决!感谢您对此事的任何帮助。

采纳答案by jdecuyper

When you launch the application, a little info mark appears at the right bottom of your screen telling you that the local web server was started and on wich port. You should compare that port to the one that appears in your browser. If they are different, an anti-virus could be responsible for that problem. Another place to look is your hostfile. Some software tweak this file and can make your localhost disbehave.

当您启动应用程序时,屏幕右下角会出现一个小信息标记,告诉您本地 Web 服务器已启动并位于哪个端口上。您应该将该端口与浏览器中显示的端口进行比较。如果它们不同,则防病毒软件可能是造成该问题的原因。另一个要查看的地方是您的主机文件。某些软件会调整此文件,并使您的本地主机不正常。

回答by JTew

Something like Fiddleror another proxy like server could cause this issue if local addresses are proxied.

如果代理本地地址,像Fiddler或其他代理(如服务器)可能会导致此问题。

You can check this under Control Panel/Internet Options - Connections Tab, Click LAN Settings down the bottom.

您可以在控制面板/Internet 选项 - 连接选项卡下进行检查,单击底部的 LAN 设置。

回答by JTew

Try adding "127.0.0.1 localhost" before the line reading "::1 localhost" in c:\windows\system32\drivers\etc\hosts

尝试在 c:\windows\system32\drivers\etc\hosts 中读取“::1 localhost”的行之前添加“127.0.0.1 localhost”

This worked for me (VS2008, Vista Ultimate)

这对我有用(VS2008,Vista Ultimate)

回答by JTew

I've the same problem, just instaled VS 2008 in a Vista Business machine. I have a LAN, but no proxy server and the c:\windows\system32\drivers\etc\hosts" with "127.0.0.1 localhost" are there. but none of my projects work, neither new ones.

我有同样的问题,只是在 Vista 商务机器上安装了 VS 2008。我有一个 LAN,但没有代理服务器和带有“127.0.0.1 localhost”的 c:\windows\system32\drivers\etc\hosts”。但我的项目都没有工作,也没有新项目。

回答by jl.

I had a similar problem on Windows 7 RC and Visual Studio 2008 SP1. Changing localhost to 127.0.0.1 helped. Similar to the hosts file solution, but doesn't require the file editing, you just need to change the project startup url.

我在 Windows 7 RC 和 Visual Studio 2008 SP1 上遇到了类似的问题。将 localhost 更改为 127.0.0.1 有所帮助。类似于hosts文件解决方案,但不需要编辑文件,只需更改项目启动url即可。

回答by Umesh Kumar Singh

"I had a similar problem on Windows 7 RC and Visual Studio 2008 SP1. Changing localhost to 127.0.0.1 helped. Similar to the hosts file solution, but doesn't require the file editing, you just need to change the project startup url."

“我在 Windows 7 RC 和 Visual Studio 2008 SP1 上遇到了类似的问题。将 localhost 更改为 127.0.0.1 有帮助。类似于主机文件解决方案,但不需要文件编辑,您只需要更改项目启动 url。 ”

This solution is working fine.......

这个解决方案工作正常......

回答by JollySwagman

I had the same problem, and when I was about to quit and run away and join a monastry I had an idea to check ELMAH - maybe it had caught it...

我遇到了同样的问题,当我即将退出并逃跑并加入修道院时,我想到了检查 ELMAH - 也许它已经抓住了它......

Sure enough, ELMAH told me it had caught this:

果然,ELMAH 告诉我它已经抓住了这个:

System.Web.HttpException (0x80004005): Maximum request length exceeded.

and this fixed it:

这修复了它:

<system.web>
  <httpRuntime maxRequestLength="65535" />
</system.web>

Good luck, Dave

祝你好运,戴夫