Talking about the need to set up IIS, mainly to implement the virtual host or not to get the IIS operating restrictions, can not add ISAP and want to implement similar to the static implementation of the program, first of all, to declare that the effect here is to achieve, Finally, you can replace the address access feature such as show.aspx?id=12345 with 12345.html, and support any extension and no extension
The part of the program to adjust is only two pieces. One is the Web.config file. The second is the link address. Required Urlrewrite.dll First download urlrewriter:http://download.microsoft.com/download/0/4/6/ 0463611e-a3f9-490d-a08c-877a83b797cf/msdnurlrewriting.msi Download After installing the bin directory to find the URLRewriter.dll file ready to start implementation. The first step: Download the Urlrewrite.dll to your Web App directory. It's all right. I put it in the bin. Then add the reference to the Urlrewrite.dll reference. Step two: Modify the web.config this step to modify a few places. Note that the location is different 1 add the following code in the Web.config file, note to be placed in <configuration> below, <appSettings/> code as follows: < Connectionstrings/> <system.web> above will be wrong <configSections> <section Name= "Rewriterconfig" type= "URLRewriter.Config.RewriterConfigSerializerSectionHandler, Urlrewriter"/> </configSections> which code is as follows: <section name= "Rewriterconfig" type= " URLRewriter.Config.RewriterConfigSerializerSectionHandler, Urlrewriter "/> for specifying configuration section" Rewriterconfig " The handler class name is "URLRewriter.Config.RewriterConfigSerializerSectionHandler", which exists in the URLRewriter.dll file in the bin directory 2 In the WebThe system.web node in the. config file adds the following code code as follows: <httpHandlers> <add verb= "*" Path = "*.html" type= "Urlrewriter.rewriterfactoryhandler, Urlrewriter"/> & nbsp <add verb= "*" path= "*" type= "Urlrewriter.rewriterfactoryhandler, URLR Ewriter "/> </httpHandlers> " This code means to have the file name extension. html and any extensions (including no extensions, excluding *.html, Because all HTTP requests for the file that this position will process first are mapped to class Urlrewriter.rewriterfactoryhandler, note the order, press from top to bottom, and if path= "*" is above, the following HTML mapping is not valid. The following steps have the settings mapped to that page 3 rewrite URL and 1, same is put under <configuration> node key is the code as follows: <REWRITERCONFIG&G T <Rules> <RewriterRule> <lookfor>~/(. +). h tml</lookfor> <sendto>~/shownews.aspx? showid=$1</sendto> </RewriterRule> <RewriterRule> <lookfor>~/(. +) </LookFor> <s Endto>~/blog.aspx? username=$1</sendto> </RewriterRule> </Rules> </ rewriterconfig> Effect: When you visit http://127.0.0.1/123.html, are you actually accessing http://127.0.0.1/Shownews.aspx? showid=123 Access HTTP://127.0.0.1/any character, the actual access is http://127.0.0.1/blog.aspx? Username= any character Note the sequence of mappings in the 2nd, 3 steps The key in the URL of the conversion code is as follows: <lookfor>~/(. +) .html</lookfor> <sendto>~/shownews.aspx? Showid=$1</sendto> means to turn the first path into another path. The regular expression in <LookFor> () is the argument in the second sentence. You can also use $ $ to represent the parameters in the second third () of <LookFor>. Multiple parameters: code as follows: <ReWriterUrls> <rule> <old> (. *)/testurlre/file (. *)/(. *) .html</old> <new>.. /webform1.aspx?id=$2&type=$3</new> </rule> <rule> <old> (. *)/testurlre/t (. *)/(. *). html</old> &NBSP;<NEW> /webform1.aspx?tid=$2&ttype=$3</new> </rule> </ReWriterUrls> The third step: in the page program can write: code as follows: <a href= "news_<%=newsid%>.html" target= "_blank" > news title </a > Completion of the above three steps can easily implement URL rewrite, but note: If you publish the site, you will find that your URL rewrite may be invalidated, if the failure of the need for you to set up IIS: Open IIS, home directory-〉 configuration-〉 mapping- Click the "Insert" wildcard application mapping-〉 Select "C:windowsmicrosoft.netframeworkv2.0.50727aspnet_isapi.dll", then remove the check (must remove), and then determine. After the above settings, you can browse the normal.