visual-studio 为什么 ASP.NET/Visual Studio Web 开发服务器这么慢?

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

Why is the ASP.NET/Visual Studio Web Development Server so slow?

c#asp.netasp.net-mvcvisual-studiodebugging

提问by Maxim Zaslavsky

Compiling - XKCD(xkcd)

编译 - XKCD( xkcd)

I know that compiling nowadays is much faster than it was before. Yet, for me, it seems that compiling and especially running/debugging ASP.NET projects with the Visual Studio Web Development Server is incredibly slow.

我知道现在编译比以前快得多。然而,对我来说,使用 Visual Studio Web Development Server编译,尤其是运行/调试 ASP.NET 项目似乎非常慢

Since the beginning of last summer, I've been working heavily on ASP.NET MVC projects. Of course, the best way to debug them is by using the web server that comes with Visual Studio. When doing that, I get horrendously slow loading times. Chrome dev tools typically report that loading one of my pages had a 3 minutewait time, followed by a short loading time.

从去年夏天开始,我一直在大量研究 ASP.NET MVC 项目。当然,调试它们的最佳方法是使用 Visual Studio 附带的 Web 服务器。这样做时,我的加载时间非常缓慢。Chrome 开发工具通常报告加载我的一个页面有3分钟的等待时间,然后是很短的加载时间。

I've seen thesetwoquestions, but they don't help. While I do most of my debugging work in Chrome, the same happens in IE.

我已经看到两个问题,但它们没有帮助。虽然我在 Chrome 中完成了大部分调试工作,但在 IE 中也会发生同样的情况。

Has anyone else had this problem before? If so, any tips?

有没有其他人遇到过这个问题?如果是这样,有什么提示吗?

Also, I doubt that the problem lies with the speed of my machine. This computer is really fast running Windows 7 and Visual Studio 2010, so I don't see why ASP.NET debugging should be so slow.

另外,我怀疑问题出在我机器的速度上。这台计算机运行 Windows 7 和 Visual Studio 2010 的速度真的很快,所以我不明白为什么 ASP.NET 调试会这么慢。



UPDATE:In his answer below, Jon Skeet suggested attempting to identify whether the problem is being caused by the environment or by the code itself. I created a brand new MVC project and ran it. The first test appeared to be much faster. However, after testing it a few more times, it's safe to say that the first test was an anomaly - usually, it takes as long as my big project (2 - 3 minutes). Thus, this is a problem with the environment. Thanks in advance for any help!

更新:在下面的回答中,Jon Skeet 建议尝试确定问题是由环境还是由代码本身引起的。我创建了一个全新的 MVC 项目并运行它。第一次测试似乎要快得多。然而,在多次测试之后,可以肯定地说第一次测试是异常的 - 通常,它需要与我的大项目一样长(2 - 3 分钟)。因此,这是环境问题。在此先感谢您的帮助!



UPDATE #2:It's been a while since I updated this question. Here are some details I've gathered since my last update:

更新 #2:我更新这个问题已经有一段时间了。以下是我自上次更新以来收集的一些详细信息:

  • This delay is occuring on both of my development machines, both running Windows 7 and Visual Studio 2010
  • This delay is happening for all my MVC2 and MVC3 projects (but I haven't experimented with plain ASP.NET yet)
  • Plain/vanilla MVC projects experience the same delay as MVC projects with big codebases
  • Disabling IntelliTrace did not help
  • Disabling IPv6 did not help
  • 这种延迟发生在我的两台运行 Windows 7 和 Visual Studio 2010 的开发机器上
  • 我所有的 MVC2 和 MVC3 项目都发生了这种延迟(但我还没有尝试过普通的 ASP.NET)
  • 普通/普通 MVC 项目与具有大型代码库的 MVC 项目经历相同的延迟
  • 禁用 IntelliTrace 没有帮助
  • 禁用 IPv6 没有帮助

I haven't found a solution for this problem, so I've been stuck with huge wait times. Does anyone know how to solve this?

我还没有找到解决这个问题的方法,所以我一直在等待很长的时间。有谁知道如何解决这个问题?

回答by Jon Skeet

There's no reason why it should take 3 minutes to start debugging something unless you've got something really strange going on.

没有理由花 3 分钟来开始调试某些东西,除非您遇到了一些非常奇怪的事情。

I suggest you launch the debugger, try to navigate to a page and then just break into the debugger while it's loading. See where you're losing time. Maybe you're making some call on startup which is failing, but taking minutes to do so.

我建议您启动调试器,尝试导航到一个页面,然后在加载时进入调试器。看看你在哪里浪费时间。也许您正在调用失败的启动程序,但需要几分钟的时间。

I've never experienced anything like what you're describing, which suggests it's either in your environment orin your code - and if it's a generally fast computer, that suggests it's somewhere in the code.

我从来没有经历过像你所描述的那样的事情,这表明它要么在你的环境中,要么在你的代码中——如果它是一台通常速度很快的计算机,那就表明它在代码中的某个地方。

If you create a brand new MVC project and debug into that, does thattake a long time?

如果您创建一个全新的MVC项目和调试成,确实需要很长的时间?

You might also want to run Wiresharkwhen you start debugging - see whether something in your app is trying to fetch a network resource of some description without you realising it.

您可能还想在开始调试时运行Wireshark- 查看您的应用程序中的某些内容是否在您没有意识到的情况下尝试获取某种描述的网络资源。

回答by Sergey

This is due to the IPv6 DNS problem within Firefox and can be fixed by setting the network.dns.disableIPv6setting to true within the about:config

这是由于 Firefox 中的 IPv6 DNS 问题,可以通过network.dns.disableIPv6about:config

Slow DNS response - Firefox on localhost and Visual Studio or Cassini

DNS 响应缓慢 - 本地主机和 Visual Studio 或 Cassini 上的 Firefox

回答by Jimmy

This is actually a known performance issue with MVC, caused by throwing a ton of exceptions internally on startup. If you have IntelliTrace turned on, this will wreck havoc with it. Try disabling IntelliTrace and see if that improves it at all.

这实际上是 MVC 的一个已知性能问题,由启动时在内部抛出大量异常引起。如果您打开了 IntelliTrace,这将对它造成严重破坏。尝试禁用 IntelliTrace,看看是否能改善它。

Source: http://connect.microsoft.com/VisualStudio/feedback/details/535799/debugging-mvc-is-very-very-slow

来源:http: //connect.microsoft.com/VisualStudio/feedback/details/535799/debugging-mvc-is-very-very-slow

回答by codelover

I met the same problem these days, working under Win7, VS2010, and developing a Silverlight solution with 10+ projects. It takes about 3 minutes to launch IE, and waits 3 minutes to get back VS after closing IE. I overcame the problem by trying different ways. But the only valuable method:

这几天我遇到了同样的问题,在 Win7、VS2010 下工作,并开发了一个包含 10 多个项目的 Silverlight 解决方案。启动IE大约需要3分钟,关闭IE后等待3分钟返回VS。我通过尝试不同的方法克服了这个问题。但唯一有价值的方法:

  1. Unload all projects not for debug
  2. Start debug the solution (it works normal )
  3. Reload other projects
  4. VS works normal here. (VS works normal)
  1. 卸载所有不用于调试的项目
  2. 开始调试解决方案(工作正常)
  3. 重新加载其他项目
  4. VS 在这里正常工作。(VS工作正常)

It seems the problem is just related with the VS environment on my side. It has nothing to do with ASP.NET Development Server or IIS.

看来问题只与我这边的VS环境有关。它与 ASP.NET 开发服务器或 IIS 无关。

回答by smnorthrop

I was having the same problem. It ended up being a problem with ColdFusion being installed on my local machine (as painful as it is for me to admit). ColdFusion puts Handler Mappings named AboMapperCustom-*that were causing the latency. I uninstalled ColdFusion because I no longer need it (thank God). Another solution could be to remove each AboMapperCustom entry through the web.config. Example:

我遇到了同样的问题。它最终成为我本地机器上安装 ColdFusion 的问题(尽管我承认这很痛苦)。ColdFusion 放置了导致延迟的名为 AboMapperCustom- * 的处理程序映射。我卸载了 ColdFusion 因为我不再需要它(感谢上帝)。另一种解决方案是通过 web.config 删除每个 AboMapperCustom 条目。例子:

<handlers>
    <remove name="AboMapperCustom-15397" />
    <remove name="AboMapperCustom-20358" />
    <remove name="AboMapperCustom-47286" />
</handlers>

Make sure the 5-digits following AboMapperCustom- match those in your local IIS Handler Mappings.

确保 AboMapperCustom- 后面的 5 位数字与您本地 IIS 处理程序映射中的数字匹配。

HTH

HTH

回答by mishal153

On Visual Studio 2012 + Win10 x64, i've noticed that if you

在 Visual Studio 2012 + Win10 x64 上,我注意到如果你

  • go to the taskbar and find the asp.net dev server there,
  • right click it and do a "show details"
  • close the box (NOT 'stop', just close via 'x')
  • 转到任务栏并在那里找到 asp.net 开发服务器,
  • 右键单击它并执行“显示详细信息”
  • 关闭框(不是“停止”,只需通过“x”关闭)

then the server loads almost instantly

然后服务器几乎立即加载