ASP.NET伪静态的方法及相关资料

1. 添加URLRewriter.dll引用

2. 配置web.config的基本信息

 <configSections>
    <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
  </configSections>
<system.web>
  <httpHandlers>
    <!--使用URLRewriter.dll    -->
  <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
  <add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />

</httpHandlers>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
<!--重写规则-->
  <RewriterConfig>
    <Rules>
      <RewriterRule>
        <LookFor>~/index.html</LookFor>
        <SendTo>~/Index.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>~/Product/detail/item/([0-9]*).html</LookFor>
        <SendTo>~/Product_Detail.aspx?ID=$1</SendTo>
      </RewriterRule>
      <!--分页规则开始-->
      <RewriterRule>
        <LookFor>~/Product/list/item/(.*)_(.*).html</LookFor>
        <SendTo>~/Product_List.aspx?ID=$1&amp;page=$2</SendTo>
      </RewriterRule>
    </Rules>
  </RewriterConfig>

 到这里伪静态就可以使用了

3.伪静态分页

  ⑴ 分页控件代码

 <webdiyer:AspNetPager ID="AspNetPager1" runat="server" FirstPageText="首页" LastPageText="尾页"
     NextPageText="下一页" PageIndexBoxType="DropDownList" PrevPageText="上一页" ShowCustomInfoSection="Left"
     ShowPageIndexBox="Always" SubmitButtonText="Go" ShowPageIndex="False" TextAfterPageIndexBox=""
     TextBeforePageIndexBox="转到" AlwaysShow="True" LayoutType="Table" CssClass="paginator"
     CustomInfoClass="paginator" CustomInfoSectionWidth="" Wrap="False" PageSize="10"
     OnPageChanging="AspNetPager1_PageChanging" UrlPaging="True">
</webdiyer:AspNetPager>

⑵ .cs代码

      AspNetPager1.UrlRewritePattern = "/Product/list/" + type + "_" + ID + "_{0}.html";

4. 相关参考质料

(1)在ASP.NET中执行URL重写

(2)ASP.NET 实现伪静态网页方法

(3)IIS7 伪静态 web.config 配置方法

(4)ASP.NET伪静态页面的实现和伪静态在IIS7.0中的配置

(5)ASP.NET伪静态实现

原文地址:https://www.cnblogs.com/liujie2272/p/5125014.html