|
最近小項(xiàng)目要求重寫url找了下資料用到了MS的2個(gè)dll,微軟的例子寫得太不明顯了。后來終于改好了。
ActionlessForm.dll------用來處理回發(fā)
URLRewriter.dll----- 是微軟封裝好了的一個(gè)URL重寫組件
添加引用----
具體的使用說明請去看
http://msdn.microsoft.com/zh-cn/library/ms972974.ASPx#XSLTsection123121120120
比我說得好得多。
具體使用方法:
首先web.config的配置:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectio
Handler,URLRewriter" />
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/ListCategories/.ASPx</LookFor>
<SendTo>~/Default.ASPx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/(/d+)/.html</LookFor>
<SendTo>~/Cover.ASPx?id=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>
</httpModules>
<compilation debug="true"/>
</system.web>
</configuration>
NET技術(shù):.NET重寫URL淺談,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。