ASP.NET pre-compilation and keep-alive

zhaozj2021-02-11  176

ASP.NET pre-compilation and keep-alive

1, pre-compilation in whidbeyasp.net is Dynamic Compilation, but some case pre-compilation is a better choice. For example, you don't want to visit the first user of your site, or you fundamentally Don't want to give your users any source code (including HTML content). Pre-compilation is very thorough in ASP.NET 2.0, you can choose In-Place pre-compilation, just you need to access: http: // Site Name / WebApp Name /Precompile.axd system will put WebApp The page will be compiled once. Or, more thorough way, Precompilation for Deployment, .NET Framework 2.0 provides a command line tool (ASPNET_COMPILER.EXE), let you compile all the code, page (including html), and static files in WebApp. Then give you a "deployment-ready webapp", no code, no html, huh, but navigate to the normal webApp. This article contains more information. 2, pre-compilation and keep-alive in .NET Framework 1.1Whidbey is next year, in fact, we can also think about some ways. The Global.asax's Global class is inherited from httpapplication, we can insert an intermediate layer to do something yourself. For example, we create a Preglobal class, inherit from httpApplication, create a new thread in the Preglobar.init () method, let this thread traverse all .aspx and .ascx in the webapp (LoadControl (on ASCX), for ASPX In httpwebrequest.create (URL) .GetResponse ()), this can implement our own "pre-compilation", then let Global inherit yourself this preglobal. We can feel that if there is no access to WebApp for a while, the speed is greatly reduced, because the CLR will automatically use the site's assembly from the memory, when accessible, load assembly, and this action It is quite time-consuming (thinking about running a WinForm on the computer, its startup time). We need a way to let our webapp always keep-alive, so that the CLR will not put it unload. Method or preglobal.init () method, we create a Timer object in this method, which is less than the default session expiration time, call "httpwebrequest.create (site url) .getResponse ()" in its ELAPSED event. Let our site always Alive. This method is seen from the Aspaliance, and the specific source is not found. 3, Delphi8D8 article also gradually get more on 9CBS.

转载请注明原文地址:https://www.9cbs.com/read-5355.html

New Post(0)