1.

        /*
* 2、
* Context.RewritePath()
* 使用给定路径重写 URL。(内部重写)
* 内部请求重写
*/
public static void TestTwo()
{
//带有参数 处理
//http://localhost:49796/testtwo/{id}
string result = "";
if (Contains(AbsolutePath, @"testtwo/\d+$", out result))
{
RewritePath(GetVirtualPath("~/test/testone.aspx?id=" + GetIntStr(result)));
} //没有参数
//http://localhost:49796/testtwo{*catchall}
if (AbsolutePath.Contains("testtwo"))
{
RewritePath(GetVirtualPath("~/test/testone.aspx"));
}
}
/*
* 3、
* Context.RewritePath()
* 使用给定路径重写 URL。(内部重写)
* 内部请求执行转移
*/
public static void TestThree()
{
//带有参数 处理
//http://localhost:49796/testtwo/{id}/{name}/
string result = "";
if (Contains(AbsolutePath, @"testthree/\d+/\w+/$", out result))
{
result = result.Replace("testthree","");
_Server.Transfer("~/test/testone.aspx?id=" + GetIntStr(result) + "&name=" + GetStringStr(result));
} //没有参数
if (AbsolutePath.Contains("testthree"))
{
_Server.Transfer("~/test/testone.aspx");
}
}

正则匹配

        //判断 制定的字符串 在源字符串中是否匹配
//返回 第一个匹配项
private static bool Contains(string source, string target, out string firstMatch)
{
firstMatch = ""; Match result = Regex.Match(source, target, RegexOptions.IgnoreCase | RegexOptions.Singleline);
if (result.Success)
{
firstMatch = result.Value;
return true;
}
return false;
} //获取字符串中的第一个数字字符匹配项
private static string GetIntStr(string source)
{
Match result = Regex.Match(source, @"(\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
if (result.Success)
{
return result.Value;
}
return "";
}
//获取字符串中 第一个字符串匹配项
private static string GetStringStr(string source)
{
Match result = Regex.Match(source, @"([a-z_]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
if (result.Success)
{
return result.Value;
}
return "";
}

2.两张图片对比区别

最新文章

  1. LINQ 左右连接
  2. java.net.UnknownHostException: promote.cache-dns.local: unknown error
  3. pt-table-checksum 检查主从数据一致性
  4. 【洛谷P3076】Taxi
  5. 关于jQuery的inArray 方法介绍
  6. Python_Day2_基础2
  7. nginx安装启动
  8. redux-actions源码解读
  9. VirtualBox 使用技巧
  10. ios 检测应用程序升级问题
  11. 【caffe-windows】 caffe-master 之Matlab中model的分类应用
  12. 【剑指offer】不用加减乘除做加法
  13. [matlab] 22.matlab图论实例 最短路问题与最小生成树 (转载)
  14. Centos7之Gcc安装
  15. BZOJ 1912: [Apio2010]patrol 巡逻 (树的直径)(详解)
  16. Spring 实现两种设计模式:工厂模式和单态模式(单例模式)
  17. MySQL中文排序
  18. 20180821 Python学习笔记:如何获取当前程序路径
  19. python list初始化技巧
  20. 数据分组、统计 case when then else end

热门文章

  1. 如何安装windows7系统
  2. oracle to_char()及to_date()函数使用
  3. 本地开发时同时启动多个tomcat服务器
  4. MD5 Tool 工具类
  5. IIS负载均衡相关
  6. 【译】神经网络与深度学习 Ch1-Section0
  7. Linux 下源码安装JDK
  8. ashx中session的使用
  9. struts2 使用jsonplugin
  10. ubuntu12.04 安装 ruby1.9.3