• UrlRewriter


    噢 噎死。。。   来看看UrlRewriter这个老古董。猛击这里下载Demo

    1、  添加 UrlRewriter.dll 到 bin目录中

    2、configSections 节点中添加

    <configSections>
        <section name="ReplaceUrl" type="URLRewriter.Config.UrlsSection, URLRewriter"/>
    </configSections>

    3、httpModules节点中添加

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

    4、aspx页面代码

    复制代码
    <%@ Page Language="C#" AutoEventWireup="true" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>UELREWRITE</title>
        <script src="JS/jquery-1.7.1.min.js" type="text/javascript"></script>
        <link href="CSS/CSS.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" language="javascript">
    
            $(function () {
                $.ajax({
                    type: "POST",
                    url: "server.action?v=" + (new Date()).valueOf(),
                    cache: false,
                    dataType: "html",
                    success: function (data) {
                        $(".i_box_6 img").attr("src", data);
                    },
                    error: function () {
                        alert("oh...oh...oh...");
                    }
                });
            });
        </script>
    </head>
    <body>
        <div class="title">
            <span>Start</span>
        </div>
        <div class="box">
            <a href="<%= ResolveUrl("index.html") %>" target="_blank">
                <div class="i_box_1">
                    <p>
                        For:Index.html</p>
                    <p>
                        To:default.aspx</p>
                </div>
            </a><a href="javascript:;">
                <div class="i_box_2">
                    <p>
                        NONE</p>
                    <p>
                        UELREWRITE</p>
                </div>
            </a><a href="<%= ResolveUrl("about.php") %>" target="_blank">
                <div class="i_box_3">
                    <p>
                        For:about.php</p>
                    <p>
                        To:Pages/Default.aspx</p>
                </div>
            </a><a href="javascript:;">
                <div class="i_box_4">
                    <p>
                        UELREWRITE</p>
                    <p>
                        NONE</p>
                </div>
            </a><a href="javascript:;">
                <div class="i_box_5">
                    <p>
                        NONE</p>
                    <p>
                        UELREWRITE</p>
                </div>
            </a><a href="javascript:;">
                <div class="i_box_6">
                    <img />
                    <p>
                        UELREWRITE</p>
                    <p>
                        NONE</p>
                </div>
            </a><a href="<%= ResolveUrl("123321/20120507.html") %>" target="_blank">
                <div class="i_box_7">
                    <p>
                        For:123321/20120507.html</p>
                    <p>
                        To:Pages/page2.aspx?ID=123321&amp;date=20120507</p>
                </div>
            </a><a href="javascript:;">
                <div class="i_box_8">
                    <p>
                        NONE</p>
                    <p>
                        UELREWRITE</p>
                </div>
            </a><a href="javascript:;">
                <div class="i_box_9">
                    <p>
                        UELREWRITE</p>
                    <p>
                        NONE</p>
                </div>
            </a><a href="<%= ResolveUrl("news/123321") %>" target="_blank">
                <div class="i_box_10">
                    <p>
                        For:news/123321</p>
                    <p>
                        To:Pages/page2.aspx?ID=123321</p>
                </div>
            </a>
        </div>
    </body>
    </html>
    复制代码

     5、要实现url重写,需要在web.config  configSections节点中设置url的映射规则

    复制代码
     <ReplaceUrl>
        <urls>
          <add virtualUrl="~/server.action" destinationUrl="~/hander.ashx"/>
          <add virtualUrl="~/index.html" destinationUrl="~/Default.aspx"/>
          <add virtualUrl="~/about.php" destinationUrl="~/Pages/Default.aspx"/>
          <add virtualUrl="~/news/(.+)" destinationUrl="~/Pages/page2.aspx?ID=$1"/>
          <add virtualUrl="~/(.*)/(.*).html" destinationUrl="~/Pages/page2.aspx?ID=$1&amp;date=$2"/>
        </urls>
      </ReplaceUrl>
    复制代码
     
    分类: ASP.NET
     
  • 相关阅读:
    安全检测点的一些梳理——待长期整理
    Tor真的匿名和安全吗?——如果是http数据,则在出口节点容易被嗅探明文流量,这就是根本问题
    prefixspan是挖掘频繁子序列,子序列不一定是连续的,当心!!!
    spark mllib prefixspan demo
    spark 2.4 java8 hello world
    有效的括号序列——算法面试刷题4(for google),考察stack
    相似的RGB颜色——算法面试刷题3(for google),考察二分
    回文的范围——算法面试刷题2(for google),考察前缀和
    最长绝对文件路径——算法面试刷题1(google),字符串处理,使用tree遍历dfs类似思路
    比较全面的gdb调试命令
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/2497546.html
Copyright © 2020-2023  润新知