Asp.net pseudo-static

Source: Internet
Author: User

On the Internet, you will often see that the address suffixes of many websites use xx. HTML or xx. aspx and other operations are similar to static file identifiers. have you ever wondered whether it is actually a static file generated one by one? What are the advantages and disadvantages of static file generation, for websites with a large volume of traffic, using static files can improve the stability and speed of the server. The disadvantage is that when a list is generated, a record is added and all related lists need to be reconstructed, of course, it is not ruled out that some companies have overcome this problem, but it is still a problem for mass programmers, and the generated version is not necessarily more dynamic than the small and medium websites, this is because management is troublesome.

Structure of the above facts, followed by pseudo-static technology, the standard is URL rewriting technology, he has the best support for the aspx format, of course, can also rewrite HTML files, however, this requires the setting of IIS, which is more convenient than the aspx format. This site uses the URL rewriting technology. This technology has obvious advantages: it is convenient for search engines to include and view, and so on. Then let's take a look at how to configure him.

First, we need to use the URL rewriting component: urlrewriter.rar

Second, you need to make some settings in Web. config:

1. Add the following nodes in <system. Web> and </system. Web> of Web. config:

<Httphandlers>
<Add verb = "*" Path = "*. aspx" type = "urlrewriter. rewriterfactoryhandler, urlrewriter"/>
<Add verb = "*" Path = "*. html" type = "urlrewriter. rewriterfactoryhandler, urlrewriter"/>
</Httphandlers>

2. Add the following nodes in <configuration> and </configuration> of Web. config:

<Configsections>
<Section name = "rewriterconfig" type = "urlrewriter. config. rewriterconfigserializersectionhandler, urlrewriter"/>
</Configsections> <rewriterconfig>
<Rules>
<Rewriterrule>
<Lookfor> ~ /D (\ D +) \. html </lookfor>
<Sendto> ~ /Default. aspx? Myid = $1 </sendto>
</Rewriterrule>
</Rules>
</Rewriterconfig>

After setting the preceding two steps, you can basically run it. The <rewriterrule/> label contains a rewritten module, and the <lookfor/> label contains the rewritten address, <sendto/> is the original address.

 

3. Configure the iis .html File
IIS configuration: website-> properties-> virtual directory-> Configuration (g)...-> ing-> wildcard application ing-> Add
Executable File: C: \ WINDOWS \ microsoft.net \ framework \ v2.0.50727 \ aspnet_isapi.dll
Extension:. html

Check whether the file exists: No.

4. After the above configuration is complete, you can access it through the following methods:

For example, if you enter Hostname/d11.html, the server will rewrite it to http: // hostname/default. aspx? Id = 11. In other words, the user enters http: // hostname/d11.html and actually accesses http: // hostname/default. aspx? Id = 11

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.