zoukankan      html  css  js  c++  java
  • 在ASP.Net2.0中使用UrlRewritingNet实现链接重写

    采用UrlRewritingNet.UrlRewriter.dll来轻松实现
    UrlRewritingNet.UrlRewriter.dll 可从其官方网站下载:
    http://www.urlrewriting.net


    0 设置之前需要添加引用:UrlRewritingNet.UrlRewriter.dll
    1 <configSections>间添加:
      <configSections>
      <section name="urlrewritingnet" restartOnExternalChanges="true" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/>
    </configSections>
    2   添加httpModules
      <httpModules>
          <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
      </httpModules>

      <system.webServer>

    <modules>
              <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/> <!--lzx add-->
        </modules>

      <system.webServer>


    3 添加链接重写的设置  <configuration> 节点下任一地方
    <urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="default.aspx" defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
      <rewrites>
       <add name="Rewrite1" virtualUrl="^http://(.*)/UrlRewritingTest/test.aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/default.aspx" rewrite="Domain" ignoreCase="true"/>
       <add name="Rewrite2" virtualUrl="^http://(.*)/UrlRewritingTest/test1.aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/info.aspx?year=2007&amp;month=3&amp;day=9" rewrite="Domain" ignoreCase="true"/>
      </rewrites>
    </urlrewritingnet>

    web.config  文件 如:

    <?xml version="1.0"?>
    <configuration>
       
    <configSections>
           
    <section name="urlrewritingnet" restartOnExternalChanges="true" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/>
       
    </configSections>
       
    <urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="default.aspx" defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
           
    <rewrites>
               
    <add name="Rewrite1" virtualUrl="^http://(.*)/UrlRewritingTest/test.aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/default.aspx" rewrite="Domain" ignoreCase="true"/>
               
    <add name="Rewrite2" virtualUrl="^http://(.*)/UrlRewritingTest/test1.aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/info.aspx?year=2007&amp;month=3&amp;day=9" rewrite="Domain" ignoreCase="true"/>
               
    <add name="Rewrite3" virtualUrl="^http://(.*)/UrlRewritingTest/test(d{4})(d{2})(d{2}).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/info.aspx?year=$2&amp;month=$3&amp;day=$4" rewrite="Domain" ignoreCase="true"/>
               
    <add name="Rewrite4" virtualUrl="^http://(.*)/UrlRewritingTest/(d{4})/(d{2})/(d{2})/info.aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/info.aspx?year=$2&amp;month=$3&amp;day=$4" rewrite="Domain" ignoreCase="true"/>
         
    <add name="Rewrite5" virtualUrl="^http://(.*)/UrlRewritingTest/stock(d{6}).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/stockinfo.aspx?code=$2" rewrite="Domain" ignoreCase="true"/>
           
    </rewrites>
       
    </urlrewritingnet>
       
    <appSettings/>
       
    <system.web>
           
    <httpModules>
               
    <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
           
    </httpModules>
           
    <compilation debug="true"/>
     
    </system.web>

     <system.webServer>

    <modules>

              <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/> <!--lzx add-->     </modules>

      <system.webServer>


    </configuration>

  • 相关阅读:
    吴恩达《机器学习》第四章:多元线性回归
    吴恩达《机器学习》第三章:矩阵和向量
    吴恩达《机器学习》第二章:线性回归
    吴恩达《机器学习》第一章:监督学习和无监督学习
    初学Go语言的学生管理系统
    vscode如何自定义补全内容,自定义常用的快捷方式?
    vscode配置Golang环境所需的bin文件夹(各种包)
    Google浏览器一开启就提示“请停用以开发者模式运行的扩展程序“解决方案
    一道把递归、链表、引用、双指针都结合的题——回文链表
    grep
  • 原文地址:https://www.cnblogs.com/hellen-li/p/3280806.html
Copyright © 2011-2022 走看看