载入中
自定义HTML载入中... loading
URL地址重写 [原创 2008-01-24 15:15:35]  删除... 
字体变小 字体变大

        这两天研究地址重写,对于那些理论性很强的东西.说实话.我也没有太看进去..经过慢慢摸索也可以实现了..地址重写了.下边记录下来也算是个学习笔记吧!!

1.将urlWrite这个类载入到项目里..

2.在web.congfig里<configuration>下边加上下边这段代码.

<configSections>
  <!-- The <configSections> element must contain a <section> tag for the <RewriterConfig> section element.
   The type of the section handler is RewriterConfigSerializerSectionHandler, which is responsible for
   deserializing the <RewriterConfig> section element into a RewriterConfig instance... -->
  <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
 </configSections>
 <RewriterConfig>
  <Rules>
   <!-- Rules for Blog Content Displayer -->
   <RewriterRule>
    <LookFor>~/Article/(\S{1,10})</LookFor>//在这里可以命名你所需要的名字.
    <SendTo><![CDATA[~/ArticleShow.aspx?id=$1]]></SendTo>  //这里是需要重写的页面.
   </RewriterRule>
   <RewriterRule>
    <LookFor>~/List/(\S{1,10})</LookFor>     //()里边s代表字符串,1,10代表字符串的长度;
    <SendTo><![CDATA[~/ArticleSort.aspx?id=$1]]></SendTo>//参数1之前一定要加上$这个符号.
   </RewriterRule>
  </Rules>
 </RewriterConfig>
3.在 <system.web>下边加上以下代码..

<httpModules>
   <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>
  </httpModules>

4.完成以上3不步就可以在本地将地址重写了..服务器的研究中...

所属版块: 科技
票数:
什么是“我顶”?
点击数:    评论数:
本文章引用通告地址(TrackBack Ping URL)为:
本文章尚未被引用。
发表评论
大 名:
(不填写则显示为匿名者)
网 址:
(您的网址,可以不填)
标 题:
内 容:
请根据下图中的字符输入验证码:
(您的评论将有可能审核后才能发表)
和讯个人门户 v1.0 | 和讯部落 | 客服中心