当文件更改时,asp.net 中的应用程序会变慢

发布于 2025-01-13 06:37:19 字数 324 浏览 0 评论 0原文

我在使用 ASP.NET 中的旧应用程序时遇到问题。 该应用程序在 Windows Server 2012 的服务器上运行,并由数百人同时使用(相同的应用程序但由不同的域指向)。

问题是这样的:每次修改 .asp 文件时,页面都会花费大量时间来“重新编译”代码,这会对使用它的用户造成损害。

如果完全相同的应用程序运行在仅由一个用户使用的另一台专用服务器上,则不会出现此问题。

我研究了好几天,发现唯一值得注意的是,在服务器iis中,如果我在应用程序池上回收->选择应用程序,效果完全相同。

我对windows server不太了解,所以请您帮忙。

谢谢你!

I have a problem with an old application in asp.net.
This application runs on a server with windows server 2012 and is used by hundreds of people at the same time (same app but which is pointed to by different domains).

The problem is this: every time I modify an .asp file, the page takes a lot of time to "recompile" the code and this causes damage to the users who use it.

This problem does not occur with the exact same application but running on another dedicated server used only by one user.

I've been researching for days, the only noteworthy thing found is that, in the server iis, if I recycle on application pool -> select the application, it has exactly the same effect.

I don't know much about windows server so I ask you for help.

Thank you!

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

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

发布评论

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

评论(2

最单纯的乌龟 2025-01-20 06:37:19

您有两种类型的部署模型。

首先是我们所说的 asp.net 网站,
其次,我们称之为 ASP.NET 网站应用程序。

它们听起来一样——但其实不然。

那么,虽然大多数人更喜欢使用“应用程序”?一个缺点是,如果您说更改后面的某些代码,则必须重新发布整个网站。这有好有坏。好处是您的代码在发布之前会被重新编译。 (事实上​​,您甚至可能想要重命名“app_code”,因为它确实由网站重新编译。

但是,在大多数情况下,网络应用程序“更难”进行小更新,因为当您发布时,您必须重新发布整个站点。但是,好的一点是,所有代码都会被编译为一个 .dll。实际上,该站点在发布之前已进行了预编译,然后您就可以了。能实际上,网站“应用程序”允许您执行诸如创建自定义登录提供程序之类的操作,这意味着整个网站都在您的开发人员控制之下。后面(源代码)不会推送到网站,

然后您就拥有了所谓的 ASP.NET 网站,这允许您修改一页的代码(后面的代码),然后推送该页面(和代码)。 ) 至该网站。重新编译该页面,您会注意到您遇到的“延迟” - 但它仅在第一次发布该页面时发生。

所以,对于一个“应用程序”,您将在 Visual Studio 中打开该项目(和一个 sln 文件)来使用。

对于网站,您可以从 Visual Studio 打开 -> 网站。

我毫无疑问更喜欢 Web 应用程序,但部署一个小的更改要困难得多,因为如上所述,您必须重新发布整个网站。

然而,这两个不同的选择将解释这种“差异”,以及为什么其他站点没有像您一样经历延迟。但是,通常在第一次加载时 - 重新发布后可能会有一段时间的延迟。这在很大程度上意味着该网站将暂时关闭以重新发布。

另外,请记住,如果您确实修改了某些文件(例如网络配置),那么这将导致应用程序池重新启动。 (如果您不使用 sql server 会话,而是使用内存中会话 - 当您执行此操作时,它们会被耗尽)。

也有可能,拥有一个用户的服务器拥有更多的内存、更多的 CPU 和更轻的负载 - 因此,进行更改后减少的延迟很可能是该服务器上的轻负载。

然而,上述两种不同的发布模型和 ASP.NET 站点类型将是首先要注意的,或者至少是要注意的第一个问题。

You have two types of deployment models.

First is what we call a asp.net web site,
and then second, is what we call a asp.net web site application.

They sound the same - but they are not.

So, while most perfer using a "application"? The ONE down side is that you have to re-publish the WHOLE site if you say change some code behind. This is good, and bad. The good part is that your code is re-compiled BEFORE you publish. (and in fact, you might even want to re-name "app_code", since that does re-compile by the web site.

However, for the most part a web applcation is "harder" to make a small update, since when you publish, you have to re-publish the whole site. But, the good part is that all code tends to be compiled down to ONE .dll. In effect the the site is pre-compiled before publishing. And with a applciaton, then you can add/change and do more things. In effect, the web site "applcation" allows you to do things like create say a custom logon provider. In most cases, this means the WHOLE site is under your developer control. It also means that code behind (source code) is NOT pushed up to the site.

Then you have what is called a asp.net web site. This allows you to say modify the code (code behind) of one page and then push that one page (and code) up to the site. The web site will thus re-compile that one page. You will note the "delay" that you experiance - but it ONLY occures the first time that page is published.

So, for a "application", you will in Visual Studio open up the project (and a sln file) is used.

For a web site, you from Visual Studio go open->web site.

I hands down prefer web applications, but they are MUCH harder to deploy a small change, since as noted, you have to re-publish the whole site.

However, the two different choices would thus explain the "difference" and as to why the other site don't experience the delay as much as you are. However, usually on first load - there can be a one time delay after a re-publish. And this quite much means the site is down for this time to re-publish.

Also, do keep in mind that if you do modify some files (such as web config), then this WILL cause the app-pool to re-start. (and if you not using sql server sessions, but in-memory sessions - they get blown out when you do this).

It also somewhat possible that the server with one user has more memory, more CPU and a much lighter load - so the reduced delay after making changes might well be the light load on that server.

However, the above two different publishing models and types of asp.net sites would be the first thing or at least the first issue to be aware of.

[旋木] 2025-01-20 06:37:19

首先,您需要确定它是网站还是 Web 应用程序项目(https://learn.microsoft.com/en-us/previous-versions/aspnet/dd547590(v=vs.110)?redirectedfrom=MSDN#Anchor_1)。 Web 应用程序的默认设置是针对单页更改进行重建,而网站的默认设置不会强制重新编译,除非修改了特殊文件夹或文件。您可以检查应用程序池的设置是否有所不同,特别是“禁用重叠回收”。您还可以检查 web.config,因为可能有一个强制重建的设置。您还想查看显式复杂化/预编译选项。

您可能需要参考以下资源: https://learn.microsoft.com/en-us/previous-versions/ms178473(v=vs.140)?redirectedfrom=MSDN

https://learn.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/determining-what-files-need-to -be-部署-cs

https://learn.microsoft.com/en-us/previous-versions/aspnet/dd547590(v=vs.110)?redirectedfrom=MSDN#Anchor_1

优化设置
https://learn.microsoft.com/en-us/archive/blogs/davidebb/a-new-flag-to-optimize-asp-net-compilation-behavior

First, you need to determine if it is a website or web application project (https://learn.microsoft.com/en-us/previous-versions/aspnet/dd547590(v=vs.110)?redirectedfrom=MSDN#Anchor_1). Default for web application is rebuild for single page changes while default for website does not force recompilation except if special folders or files are modified. You may check to see if any settings for the app pool differ-- in particular "Disable Overlapping Recycle". You may also check the web.config as there may be a setting that is forcing rebuild. You want also want to look at Explicit Complication/pre-compilation option.

You may want to reference the following resources: https://learn.microsoft.com/en-us/previous-versions/ms178473(v=vs.140)?redirectedfrom=MSDN

https://learn.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/determining-what-files-need-to-be-deployed-cs

https://learn.microsoft.com/en-us/previous-versions/aspnet/dd547590(v=vs.110)?redirectedfrom=MSDN#Anchor_1

Optimization setting
https://learn.microsoft.com/en-us/archive/blogs/davidebb/a-new-flag-to-optimize-asp-net-compilation-behavior

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