Visual Studio - 为什么 .ASPX 文件的加载时间比 .ASPX.CS 文件长得多?

发布于 2024-07-13 21:26:03 字数 284 浏览 6 评论 0原文

这可能是一个愚蠢的问题,但它经常让我烦恼,所以我想在这里问也没什么坏处。

当我打开 .ASPX 文件时,Visual Studio 到底在做什么,并且比仅打开代码隐藏文件 (.ASPX.CS) 花费的时间要长 4-5 秒。

我注意到 VS 2003、2005 和 2008 以及新建的机器上也发生过这种情况,所以这不是我的开发机器太慢的问题。

不过,它似乎只在特定会话中首次打开任何 .ASPX 文件时才会发生。 是否有一些正在进行的处理我可以禁用以消除这种延迟?

干杯

This may be a stupid question, but it's something that bugs me on a regular basis, so no harm in asking here I guess.

What exactly is Visual Studio doing when I open up an .ASPX file and it takes a good 4-5 seconds longer than if I was just opening the code behind file (.ASPX.CS).

I've noticed this happening with VS 2003, 2005 and 2008, and on a newly built machine too, so it's not an issue of my dev machine being too slow.

It seems to only happen when opening any .ASPX file for the first time in a particular session though. Is there some processing going on that I can disable to get rid of this delay?

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

神也荒唐 2024-07-20 21:26:03

因为 Visual Studio 必须处理 aspx 文件才能在设计视图中表示它们。 源文件没有设计视图。

它可能会缓存设计视图所需的内容。 这将使下次加载文件时速度更快。

Because Visual Studio has to process the aspx files to represent them in design view. Source files do not have a design view.

It probably caches what it needs for design view. This will make things faster the next time it wants to load the file.

公布 2024-07-20 21:26:03

我刚刚禁用了 HTML 设计器:

Tools -> Options -> HTML Designer ->
"Enable HTML designer" uptick it.

工作速度更快。 在 VS12 中测试。

I just disabled HTML designer:

Tools -> Options -> HTML Designer ->
"Enable HTML designer" uptick it.

Works much more faster. Tested in VS12.

二智少女猫性小仙女 2024-07-20 21:26:03

为了加快 VS 打开 .aspx 文件的速度,您可以右键单击它们并选择“查看标记”,这将直接带您进入 HTML,而无需打开设计视图。

当然,一旦您尝试再次切换到设计视图,就需要几秒钟的时间来加载页面。

To speed up VS opening .aspx files, you can right-click on them and choose View Markup, which will take you directly to the HTML without it opening the design view.

Of course as soon as you try to switch to design view again it'll take a couple seconds to load the page up.

孤独患者 2024-07-20 21:26:03

您可以采纳 weiran 的建议,或者如果您只想双击 da aspx 文件而没有延迟麻烦...在 VS 中,转到:

工具 -> 。 HTML 设计器 ->

“起始页位于”部分 - 选择“源代码视图”

“智能标记”部分 - 取消选中“自动显示智能标记...视图”

You can take weiran´s advice or if you just want to double-click da aspx file without the delay hassle...In VS go to:

Tools -> HTML Designer ->

"Start Pages in" section - pick "Source View"

"Smart Tags" section - Uncheck "Automatically display Smart Tags....view"

烟─花易冷 2024-07-20 21:26:03

另一个可能的原因是 Web.Config 的 // 部分中定义的自定义用户控件的数量和复杂性。 从 Web.Config 中删除它们显着提高了 Visual Studio(特别是 VS 2010)中加载 aspx 和 ascx 文件的速度。 当然,它们需要在使用它们的 aspx/ascx 文件中注册,但我不会为每个文件支付罚款。

Another possible reason is the number and complexity of custom user controls defined in Web.Config in the <system.web>/<pages>/<controls> section. Removing them from the Web.Config significantly improved the speed at which aspx and ascx files loaded in Visual Studio (VS 2010 specifically). Of course, they need to be registered in the aspx/ascx files that use them, but I don't pay the penalty on every file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文