How to implement static _ practical skills for ASP.net website

Source: Internet
Author: User

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.

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.