Implementation of aspx rewrite to HTML suffix

Source: Internet
Author: User
Implementation of aspx rewrite to HTML suffix

SeriesArticleDirectory

I. pseudo-static mode (using urlrewriter)
1. Rewrite method (article address: http://www.cnblogs.com/scottckt/archive/2011/01/12/1933737.html)
2. Processing Method for sending back (article address: http://www.cnblogs.com/scottckt/archive/2011/01/12/1933791.html)
3. Rewrite aspx to HTML method (article address: http://www.cnblogs.com/scottckt/archive/2011/01/12/1933836.html)

2. Real rewriting (using system. Web. Routing) (article address: http://www.cnblogs.com/scottckt/archive/2011/01/12/1933893.html)

 

This method is similar to the pseudo-static method. We still use the example rewritertester provided by Microsoft as an example.

1. Reference DLL

First, you need to reference the two DLL mentioned in the previous article in your project, namely urlrewriter. dll and actionlessform. dll.

 

2. Configure the Web. config file

 

 

< Configsections >
< Section Name = "Rewriterconfig" Type = "Urlrewriter. config. rewriterconfigserializersectionhandler, urlrewriter"   />
</ Configsections >

Code < Rewriterconfig >
< Rules >
<! --
Rules for Blog content Displayer
To facilitate observation. I deleted the appx IN THE RULE <lookfor>.
-->
< Rewriterrule >
< Lookfor > ~ /(\ D {4})/(\ D {2})/(\ D {2}) \. html </ Lookfor >
< Sendto > ~ /Showblogcontent. aspx? Year = $1 & Amp; Month = $2 & Amp; Day = $3 </ Sendto >
</ Rewriterrule >
< Rewriterrule >
< Lookfor > ~ /(\ D {4})/(\ D {2})/Default \. Html </ Lookfor >
< Sendto > <! [CDATA [ ~ /Showblogcontent. aspx? Year = $1 & month = $2 ]> </ Sendto >
</ Rewriterrule >
< Rewriterrule >
< Lookfor > ~ /(\ D {4})/Default \. Html </ Lookfor >
< Sendto > ~ /Showblogcontent. aspx? Year = $1 </ Sendto >
</ Rewriterrule >
< Rewriterrule >
< Lookfor > ~ /Default \. Html </ Lookfor >
< Sendto > ~ /Default. aspx </ Sendto >
</ Rewriterrule >
......

< System. Web >
< Httphandlers >  
< Add Verb = "*" Path = "*. Aspx" Type = "Urlrewriter. rewriterfactoryhandler, urlrewriter"   />  
< Add Verb = "*" Path = "*. Html" Type = "Urlrewriter. rewriterfactoryhandler, urlrewriter"   />  
</ Httphandlers >
</ System. Web >

 

 

3. Configure the iis .html File
Iis6.0 configuration method

Website-> properties-> virtual directory-> Configuration (g)...-> ing-> wildcard ApplicationProgramIng-> Add
Executable File: C: \ WINDOWS \ microsoft.net \ framework \ v2.0.50727 \ aspnet_isapi.dll
Extension:. html

Check whether the file exists: No.

How to configure iis7.5

Your website --> handler ing in IIS -->
Add script ing (Path: *. html Executable File % WinDir % \ Microsoft. NET \ framework \ v2.0.50727 \ aspnet_isapi.dll name: arbitrary, such as hml)
Add wildcard script ing (Path: * Executable File: C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 \ aspnet_isapi.dll name: arbitrary, such as all)
Managed handler ing (Path: * Executable File: system. Web. UI. pagehandlerfactory name, for example, HTML-integrate) -------->
Module in IIS --> Add ----> (Name: any type such as all: urlrewriter. modulerewriter hooks OK for sending requests only to the Asp.net application or managed handler)
--> OK

4. Test

Run the project, enter http: // hostname/default.html in the address bar, and the server will point to http: // hostname/ /Default. aspx .

 

 

 

 

Reference: http://www.cnblogs.com/xiachufeng/archive/2010/08/29/1812063.html

 

 

 

 

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.