简单实用的重写URL(URLRewriter.dll)


 简单实用的重写URL(URLRewriter.dll),URLrewriter.dll可以微软官方网站下载,比较旧的东西了
大概记录一下实现的方法
修改web.cofing
在<configuration>节点内加入引用程序集

  

  <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
 </configSections>
重写URL  <RewriterConfig>
  <Rules>
    <!--重写按年查询地址-->
    <RewriterRule>
      <LookFor>~/content_list_year,(d{1,9}),(d{1,9}),(d{4}).aspx</LookFor>
      <SendTo><![CDATA[~/Test.aspx?bigtypeid={GetProperty(Content)}&smalltypeid=$2&postyear=$3]]></SendTo>
    </RewriterRule>
    <!--重写评论地址-->
    <RewriterRule>
      <LookFor>~/comment,(d{1,9}).aspx</LookFor>
      <SendTo><![CDATA[~/comment.aspx?PostID={GetProperty(Content)}]]></SendTo>
    </RewriterRule>

  </Rules>
 </RewriterConfig>

(注:重写的URL要以aspx结尾,如想输入目录达到URL重写要在目录下创建一个default.aspx(IIS中的默认档))

  我说的可能不是很详细,看微软提供的代码吧)

  http://www.microsoft.com/china/msdn/library/webservices/asp.net/URLRewriting.mspx

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3