Asp. NET technology to implement a page with the extension. Aspx,aspx is a very popular Dynamic Web page format. Dynamic Web page is a feature of information interaction, update timely, less paging file, the development of fast. But it's a serious problem is that the traffic is relatively large, and the server configuration and resources are relatively limited, each visit may be frequent processing of program logic, read and write database, etc., reduce server performance.
Tools/raw Materials
asp.net
static method One:
Rewrite the Render () method of the dynamic page. cs file that each page needs to be static, as shown in the following figure. Notice the red box, and the parameters at the red box indicate the name of the static page you want to generate. The method is simple to implement, but each time the page is accessed, the render () method is executed again, generating a page with low performance.
static method Two:
1. Re-create an ASPX page that is designed to generate static pages for each dynamic aspx page. As shown in the following illustration, only the content page and master page are generated as static pages, of course This example is a simple example, the actual situation is very complex, but the principle is the same.
2, Generate content page:
The different content pages in this example are differentiated by different IDs, enter a different ID value, click the "Generate Content Page" button, and the call executes the background code (pictured below) to generate an HTML page.
If the content of the content page changes, perform the steps above again to regenerate it.
The parameters in the following figure code represent dynamic URLs, static web site paths, static file names, and need to be modified more realistically.
3, generate the main page:
Click on the "Generate Home" button at the front desk to execute the background code (as shown in the following illustration) to generate the homepage HTML. If the content of the home page changes, rebuild it. The parameters in the following figure code need to be modified according to the actual situation.
This experience provides a simple example of 2 ways to generate static pages, the actual situation may be more complex, but the principle is the same.