这种方法可以隐藏你的页面扩展名,在页面传值的时候也可以做成伪静态,这样就可以提高搜索引擎的友好性。

引入UrlRewritingNet.UrlRewriter.dll(我用的版本是:2.0.60829.1)

改配置文件,在Web.config中的<configuration></configuration>节点间加入代码
<configSections>
    <section name="urlrewritingnet" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/>
</configSections>
<urlrewritingnet rewriteOnlyVirtualUrls="true" defaultPage="index.html" contextItemsPrefix="QueryString" defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
   <!--用时将这里的注释去掉,这里的具体语意可在网上查到
      <add name="RewriteOnDomain" virtualUrl="^http\://(.*)/SampleWeb/domain/(.*)/Detail(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Default.aspx?language=$3&amp;id=$4;&amp;domain=$1" rewrite="Domain" ignoreCase="true"/>
      <add name="Rewrite" virtualUrl="^~/(.*)/Detail(.*).html" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Default.aspx?language=$1&amp;id=$2" ignoreCase="true"/>
      <add name="RedirectInApplication" virtualUrl="^~/(.*)/Default.aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/$1/Detail_Redirected.aspx" redirect="Application" redirectMode="Permanent" ignoreCase="true"/>
      <add name="KickBrowserToDomain" virtualUrl="^http\://(.*)/SampleWeb/kickto/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="http://$2?source=$1" redirect="Domain" redirectMode="Permanent" ignoreCase="true"/>
      <add name="myurl" virtualUrl="^~/testurl/(.*)/(.*).html" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/testurl.aspx?name=$1&amp;show=$2" ignoreCase="true"/>
      <add name="myurl2" virtualUrl="^~/testurl-(.*)-(.*).html" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/testurl.aspx?name=$1&amp;show=$2" ignoreCase="true"/>
      <add name="myurl3" virtualUrl="^~/url.html" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/testurl.aspx?name=a&amp;show=b" ignoreCase="true"/>
   -->
</rewrites>
</urlrewritingnet>
<configuration>节点中的<system.web></system.web>间加入
      <httpModules>
        <add name="HttpCompressionModule" type="AjaxPro.HttpCompressionModule,AjaxPro.2"/>
        <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
      </httpModules>