Using HttpHandler to generate static pages

Source: Internet
Author: User

After looking at the static page conversion platform (STATICPOL)-static page Generation Ultimate solution, I have done this thing I put up now, is also turned into static pages, limited to dotnet use (I was treated with HttpHandler), and also very simple, mainly to achieve the function I want, The shortfall is certainly a lot of (I will mention two points later), I hope not to delay your time.

Here's a concrete implementation:

The configuration in the 1.web.config

<!--configuration policy config file address-->

<appSettings>
<add key= "ConfigFilePath" value= "Config/statictactic.config"/>
</ Appsettings> ...
(omitted)
<!--configuration httphandler-->

2. Policy configuration file

<!--

Rules.root: Generated static pages in the Web site root directory folder

Rules.timespan: Default Expiration Time difference (in minutes)

LookFor: Pages that need to generate static pages

TimeSpan: The Expiration time difference for static pages (in minutes)

-->
<StaticTacConfig>
<rules root= "HTML" timespan= "> <tacrule lookfor=
" Default.aspx ">
<TimeSpan>1</TimeSpan>
</TacRule>
<tacrule lookfor=" product/ Sort.aspx ">
<TimeSpan>10</TimeSpan>
</TacRule>
</Rules>
</ Statictacconfig>

3.HttpHandler implementation of this relatively simple, we look at the source code will know. The main is to determine whether the requested page needs to generate static pages, if necessary, to determine whether the static page exists or exists but has expired does not exist, or exist but the outdated pages need to be regenerated.

This article supporting source code

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.