遭遇Intelligencia.UrlRewriter

UrlRewriter.Net重定向开源项目.

使用心得:

1.配置.

web.config里加三个节点:

1). 加入UrlRewriter的配置

<configSections>
    <section name="rewriter" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
</configSections>

2).   UrlRewriter的配置

  <rewriter>
    <if url="(.*)\.html(.*)" rewrite="$1.aspx$2"/>
    <if url="(.*)fckeditor/editor/(.*)\.aspx(.*)" rewrite="$1fckeditor/editor/$2.html$3"/>
  </rewriter>

说明:这里定义转换规则,顺序执行.也就是说在越前面的可以定义越广的泛围.个别情况可以在后面的规则中再做调整.按这个理解,规则应该是越少越好,以免影响效率.

3).  使用 在system.web

    <httpModules>
      <add type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" name="UrlRewriter"/>
    </httpModules>

2.对Form的action的处理.使用UrlRewriter定义的Form,以达到PostBack的时候,保持Url的效果.

1)引用.在Page.aspx

<%@ Register TagPrefix="UR" Namespace="Intelligencia.UrlRewriter" Assembly="Intelligencia.UrlRewriter" %>

2). 使用Form:

 <UR:form  id="from1" runat="server" >

</UR:form >

原文地址:https://www.cnblogs.com/greatqn/p/627621.html