asp.net pre-compilation and keep-alive

Source: Internet
Author: User
Tags thread
asp.net

asp.net pre-compilation and keep-alive
1, pre-compilation in Whidbey

Asp. NET is a major feature is dynamic compilation, but some occasions pre-compilation is a better choice, for example, you do not want to visit your site's first users silly waiting, or you do not want to have any source code (including HTML content) to your users.

Pre-compilation in ASP.net 2.0 support very thoroughly, you can choose In-place pre-compilation, only need you to visit:
http://site name/webapp name/precompile.axd
The system will webapp all the pages in the first compiled to you.

Or, in a more thorough way, precompilation for Deployment,.net Framework 2.0 provides a command-line tool (Aspnet_compiler.exe) that allows you to webapp all the code, Page (including Html), static files are all compiled into the DLL, and then give you a "Deployment-ready WebApp", no Code, no Html, hehe, but browse up and ordinary WebApp no difference.

This article contains more information.

2, Pre-compilation and keep-alive in. NET Framework 1.1

After all, Whidbey is next year, in fact, we can also think of some ways now.

The global class inside the Global.asax is inherited from HttpApplication, and we can insert ourselves into an intermediate layer to do some of our own things. For example, we create a Preglobal class, inherit from HttpApplication, in the Preglobar.init () method, create a new thread, Let this thread traverse through all of the. aspx and. ascx in the WebApp (LoadControl () to ascx, httpwebrequest.create (URL) to aspx. GetResponse ()), so that we can achieve our own "pre-compilation", and then let global inherit from our own this preglobal.

We can feel that if you do not have access to webapp for a while, the speed is greatly reduced when you visit again, because the CLR automatically unload the site's assembly from memory, and when you visit again, load the assembly, And this action is quite time-consuming (think about running a WinForm on a computer, its startup time). We need to think of a way to keep our webapp always keep-alive so that the CLR does not unload it. method or the Preglobal.init () method, we create a timer object in this method, which is less than the default session expiration time, and calls "Httpwebrequest.create" in its Elapsed event (site URL ). GetResponse () "Can let our site always alive."

This method is from the view of aspaliance, the specific source has not been found.

3, Delphi8

D8 's article on the CSDN also gradually more up. If you don't hate Pascal's syntax, then the file in the source directory of the D8 installation directory is really a good learning. NET resource, which has D8 RTL, Vcl.net, indy.net, Web data-aware control implementation of the source code, At the very least, see how D8 combines its stuff with the. NET thing.

For example, in the Borland.Delphi.System.pas inside, I saw TObject = System.Object, hehe, and we imagined the same. In Borland.Vcl.Classes.pas, I see that Tlist has a private member Flist is System.Collections.ArrayList type, so obviously tlist is achieved by aggregating ArrayList. And in the Borland.Vcl.Forms.pas inside, you can see Tform is inherited from the Tcustomform, and then the above is Tscrollingwincontrol, Twincontrol, Tcontrol ... It has nothing to do with System.Windows.Forms.Form, which is why D8 Vcl.net app and win app, VCL. NET many of the controls are still borland in their own way (although they are written by managed code) and they are not necessarily compatible with WinForms.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.