我爱Aspx >> Asp.Net >> UrlReWriter 使用经验小结UrlRewriter 是微软封装好了的一个URL重写组件。使用它可以让我节约很多自已开发的时间。
好了,开始讲述我的应用经验,这只是很菜鸟的经验,高手就不用看了。
第一步,请从此下载此组件。解压,把UrlRewriter.dll copy到你的项目 bin 目录下。
第二步,在Web.config中加入:
<?xml version="1.0" encoding="gb2312" ?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
第二步,加入重写的规则节点:
如:
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/Sell/(.[0-9]*)\.html</LookFor>
<SendTo>~/Search/Search_Sell.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Sell/Search_Sell\.aspx</LookFor>
<SendTo>~/Search/Search_Sell.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Buy/(.[0-9]*)\.html</LookFor>
<SendTo>~/Search/Search_Buy.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Buys/(.[0-9]*)\.html</LookFor>
<SendTo>~/Buys/Show.aspx?id=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
这个就要根据你的需要了,如果你对正则表达式不熟,那么没办法,要么凭借你的高智商去找其中规律,稍稍改一下就能为你所用了。呵呵。如果实在搞不清,那就自己GOOGLE一下正则表达式吧。(本人开始是参考别人的配置猜的,竟然用对了,呵呵。后来还是看了一下相关资料,发现这东东很有用。)
Ҷƪл˵?
RadioButton Web 控件[04-29]
RadioButtonList Web 控件[04-29]
ListItem Web 控件[04-29]
CheckBox Web 控件[04-29]
CheckBoxList 控件[04-29]
DropDownList Web 控件[04-29]
DropDownList Web 控件[04-29]
RequireFieldValidator Web 控件[04-29]
ListBox Web 控件[04-29]
进阶Web控件--数据验证Web控件[04-29]