asp.net网站页面转成伪静态

来源:互联网 发布:js数组添加数据 编辑:程序博客网 时间:2024/04/30 08:33

第一步,将URLRewriter.dll拷贝至bin目录。
第二步,配置web.config,注册dll并编写规则,如下:
        <configSections>
            <section name="RewriterConfig" requirePermission="false" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,URLRewriter" />
        </configSections>

<RewriterConfig>
        <Rules>
          <RewriterRule>
            <LookFor>~/product/ProductList/(\d{0,999999})\.html</LookFor>
            <SendTo><![CDATA[~/product/ProductList.aspx?type=Category&ID=$1]]></SendTo>
          </RewriterRule>
          <RewriterRule>
            <LookFor>~/product/ProductList/(\d{0,999999})/(\d{0,999999})/([\S]+)/(\d{0,999999})</LookFor>
            <SendTo><![CDATA[~/product/Productlist.aspx?CategoryID=$1&ProductName=$2&txtKey=$3&Page=$4]]></SendTo>
          </RewriterRule>
        </Rules>
   </RewriterConfig>


    //将dll添加到httpHandlers和httpModules
    <httpHandlers>
      <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
    </httpHandlers>
    <httpModules>
      <add name="ModuleRewriter" type="URLRewriter.ModuleRewriter,URLRewriter" />
    </httpModules>


第三步,完成web.config配置以后,向IIS服务器添加用于处理web请求的处理程序映射,如图:
   

URLRewriter控件制作伪静态示例 - skybirdzw - skybirdzw的博客

 

原创粉丝点击