URL映射

1.web.config
<configuration>
    
<configSections>
        
<section name="rewriter" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
    
</configSections>
    
<appSettings>
    
</appSettings>
    
<connectionStrings/>
    
<system.web>
        
<authentication mode="Windows"/>
        
<httpModules>
            
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
        
</httpModules>
        
<!--<compilation debug="true"/>-->
        
<compilation debug="true"/>
  
</system.web>
    
<rewriter>
        
<rewrite url="~/products/(.+).aspx" to="~/products.aspx?category=$1"/>
        
<rewrite url="~/showdetail/(.+).aspx" to="~/showdetail.aspx?id=$1"/>
        
<rewrite url="~/show/(\d{4})/(\d{2})/(\d{2})\.html" to="~/show.aspx?year=$1&amp;month=$2&amp;day=$3"/>
    
</rewriter>
</configuration>

2.Default.aspx
<asp:HyperLink ID="HyperLink1" runat="server" Height="28px" NavigateUrl="show/2007/05/16.html" Width="158px">show/2007/05/16.html</asp:HyperLink>

3.show.aspx
 protected void Page_Load(object sender, EventArgs e)
    
{
        
this.Label1.Text = Request.QueryString["year"].ToString()+Request["month"].ToString()+Request["day"].ToString();
    }

4.结果
posted @ 2007-05-16 01:14  yongwnet  阅读(278)  评论(0编辑  收藏  举报