About pseudo-static

Source: Internet
Author: User

Some time ago, we made a website for our customers. This website also needs to be optimized, which is also done by our company. In order to make it easier for the optimization personnel to get the search engine to include the website more quickly, or to generate static whole site, otherwise, it is written as pseudo-static. For a new employee, the whole site has not been used to generate static data, and the pseudo-static data has not been used. By reading the masterpiece of the great gods on the internet, I have learned a little about it. It is really good to generate full-site static data. It is said that it will occupy resources and cause heavy damage to the hard disk, so I will focus on pseudo-static data.
I have found several pseudo-static implementation methods by asking some experts and online materials, but I need to configure iis. The aspnet_isapi.dll of ingress can be used, which is more convenient. Okay. Let's talk about the code.
Here are just some of my personal methods. There are certainly many good ways to implement them. I hope you will share your thoughts and learn together.

First, create a solution with random names based on your hobbies. Here is my test.
Create two. aspx files, such as a. aspx and B. aspx.
Then add the following code to the Global. asax file:
[Csharp]
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. Security;
Using System. Web. SessionState;
Using System. Text. RegularExpressions;
 
Namespace URLReWrite1
{
Public class Global: System. Web. HttpApplication
{
 
Void Application_Start (object sender, EventArgs e)
{
// Code that runs when the application starts
 
}
 
Void Application_End (object sender, EventArgs e)
{
// Code that runs when the application is closed
 
}
 
Void Application_Error (object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
 
}
Protected void Application_BeginRequest (Object sender, EventArgs e)
{
Regex reg = new Regex (". + B-(\ d +)-(\ d1_0000.html ");
Var macth = reg. Match (HttpContext. Current. Request. Url. AbsolutePath );
If (macth. Success)
{
String uid = macth. Groups [1]. Value;
String spid = macth. Groups [2]. Value;
HttpContext. Current. RewritePath (String. Format ("B. aspx? Uid = {0} & spid = {1} ", uid, spid ));
}
}
Void Session_Start (object sender, EventArgs e)
{
// The code that runs when the new session starts

}
 
Void Session_End (object sender, EventArgs e)
{
// The code that runs when the session ends.
// Note: Only the sessionstate mode in the Web. config file is set
// The Session_End event is triggered only when InProc is used. If the session mode is set to StateServer
// Or SQLServer, the event is not triggered.
 
}
 
}
}

 

Add a hyperlink to the. aspx file.
[Csharp]
<Span style = "font-size: 18px;">

Now, you need to configure iis to add an application extension. aspx for your website. The path is C: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727 \ aspnet_isapi.dll.
Then, expand it to .html. The path is still C: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727 \ aspnet_isapi.dll.
You have to select the correct version to view the test website and click test. The following url displays b-123-111.html.
In this way, a simple pseudo-static state is implemented. I hope you can give me more instructions on how to add a virtual directory. That is, the directory does not exist and you want to display it in the url, for example, as a/b-123-111.html. I look forward to learning your thoughts.

 

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.