URLRewrite伪静态与AspNetPager分页控件的结合

分页的时候我们也希望url是伪静态的,那么如下操作就ok了

前台显示页面: 其中 EnableUrlRewriting="true" UrlRewritePattern="~/ck_chanpin_{0}.html" 这句非常重要

<webdiyer:AspNetPager ID="myAspNetPager" runat="server" AlwaysShow="false" CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条"
            Font
-Size="12px" HorizontalAlign="center" OnPageChanged="myAspNetPager_OnPageChanged" ShowCustomInfoSection="Right" Width="100%" 
            CssClass
="neirong-1" FirstPageText="首 " LastPageText="末 " NextPageText="下一页" PrevPageText="上一页" 
            PageSize
="10"
            EnableUrlRewriting
="true"
            UrlRewritePattern
="~/ck_chanpin_{0}.html"
            
>

Web.config:

   <!-- 开始 -->
  
<configSections>
  
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
  
</configSections>
  
<RewriterConfig>
  
<Rules>
    
<RewriterRule>
    
<LookFor>~/ck_chanpin_(\d+).html</LookFor>
    
<SendTo>~/ck_chanpin.aspx?page=$1</SendTo>
    
</RewriterRule>
  
</Rules>
</RewriterConfig> 
<!-- 结束 -->
<system.web>
    
<httpHandlers>
      
<add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />
      
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
      
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
    
</httpHandlers>
</system.web>

你可能感兴趣的:(urlrewrite)