How to achieve static ASP. NET Website, asp.net achieve static
The extension of pages implemented by ASP. NET is. aspx, which is a popular dynamic webpage format. Dynamic Web pages are characterized by information interaction and timely updates, with fewer page files and fast development speed. However, a serious problem is that when the traffic volume is large and the server configuration and resources are limited, each access may frequently process program logic, read/write databases, and so on, reduces server performance.
Tools/Raw Materials
Asp.net
Static Method 1:
Rewrite the Render () method of the static dynamic page. cs file for each page, as shown in. Note that the parameter in the red box indicates the name of the static page to be generated. This method is easy to implement, but every time you access the page, the Render () method is re-executed to generate the page, with low performance.
Static Method 2:
1. Recreate An aspx page to generate a static page for each dynamic aspx page. As shown in, only static pages are generated on the Content Page and home page. Of course, this example is a simple example. The actual situation is complex, but the principles are the same.
2. Generate the content page:
In this example, different content pages are differentiated by different IDs. Enter different ID values and click "generate content page" to call and execute background code (for example ), generate an html page.
If the content on the Content Page changes, execute the preceding step again and generate a new one.
The parameters in the Code indicate the dynamic url, static website path, and static file name, which must be modified in a more practical way.
3. Generate the Home Page:
Directly click the "generate Homepage" button on the foreground to execute the background code (as shown in) and generate the homepage html. If the content of the home page changes, generate a new one. The parameters in the Code must be modified according to the actual situation.
This experience provides two ideas and methods for generating static pages using a simple example. The actual situation may be more complex, but the principles are the same.