ASP.NET实现伪静态化 -- UrlRewritingNet

MSDN上有一篇很详细的文章

http://msdn.microsoft.com/zh-cn/library/ms972974.aspx

但是我用的是另一个:UrlRewritingNet控件

它的使用方法很简单:

1.将UrlRewritingNet.UrlRewriter.dll拷到bin目录下。 下载

2.在web.config里进行相关的配置
<? xml version="1.0" ?>
< configuration >
    
< configSections >
        
< section name ="urlrewritingnet" requirePermission ="false" type ="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />
    
</ configSections >

    
< urlrewritingnet rewriteOnlyVirtualUrls ="true" contextItemsPrefix ="QueryString" defaultPage = "default.aspx" defaultProvider ="RegEx" xmlns ="http://www.urlrewriting.net/schemas/config/2006/07" >
        
< rewrites >
            
< add name ="Rewrite"    virtualUrl ="^~/(.*)/Detail(.*).aspx"
                  rewriteUrlParameter
="ExcludeFromClientQueryString"
                  destinationUrl
="~/Default.aspx?type=$1&id=$2"
                  ignoreCase
="true" />
        
</ rewrites >
    
</ urlrewritingnet >

    
< appSettings />
    
< connectionStrings />
    
< system.web >
        
< compilation debug ="true" />
        
< authentication mode ="Windows" />
        
< httpModules >
            
< add name ="UrlRewriteModule"
                  type
="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
        
</ httpModules >
    
</ system.web >
</ configuration >
大功告成!关键的2步都在这了,至于涉及的正则表达式等其它方面我也不懂,靠Google了。

你可能感兴趣的:(asp.net)