Asp.net URL重写脚本
来源:互联网 发布:汉服淘宝店平价学生党 编辑:程序博客网 时间:2024/06/07 06:56
void context_BeginRequest(object sender, EventArgs e) { HttpApplication application = (HttpApplication)sender; HttpContext context = application.Context; HttpResponse response = context.Response; string path = context.Request.Path; string file = System.IO.Path.GetFileName(path); //重写后的URL地址 Regex regex = new Regex("InfoLists-(\\d+).aspx", RegexOptions.Compiled); Match match = regex.Match(file); //如果满足URL地址重写的条件 if (match.Success) { string userId = match.Groups[1].Value; string rewritePath = "InfoLists.aspx?id=" + userId; //将其按照UserInfo.aspx?UserId=123这样的形式重写,确保能正常执行 context.RewritePath(rewritePath); } Regex regex1 = new Regex("InfoDetail-(\\d+).aspx", RegexOptions.Compiled); Match match1 = regex1.Match(file); //如果满足URL地址重写的条件 if (match1.Success) { string id = match1.Groups[1].Value; string rewritePath = "InfoDetail.aspx?id="+ id; //将其按照UserInfo.aspx?UserId=123这样的形式重写,确保能正常执行 context.RewritePath(rewritePath); } Regex regex2 = new Regex("InfoList-(\\d+)-(\\d+).aspx", RegexOptions.Compiled); Match match2 = regex2.Match(file); //如果满足URL地址重写的条件 if (match2.Success) { string parentid = match2.Groups[1].Value; string id = match2.Groups[2].Value; string rewritePath = "InfoList.aspx?parentid=" + parentid + "&id=" + id; //将其按照UserInfo.aspx?UserId=123这样的形式重写,确保能正常执行 context.RewritePath(rewritePath); } } #endregion
0 0
- Asp.net URL重写脚本
- ASP.NET URL重写
- ASP.NET URL重写
- URL 重写(Asp.Net)
- asp.net url重写
- asp.net url重写
- url重写 asp.net
- asp.net url重写
- ASP.NET重写URL
- asp.net url重写
- asp.net url重写
- asp.net url 重写
- asp.net URL重写
- ASP.NET URL重写
- ASP.NET URL重写
- asp.net重写URL
- asp.net Url重写
- asp.net url重写
- 20141103 N2
- RTSP & RTP & RTCP的理解
- 页面编码为GBK时 jquery 提交ajax数据完美解决"中文乱码"方案
- 微软为何要收购诺基亚?
- POJ3349
- Asp.net URL重写脚本
- [Erlang]hello world”与<<”hello world”>>详解(1)
- linux 通过rpm包安装和配置 jenkins
- 网站性能优化
- CC2530显示屏小实验时遇到的问题
- java c/cpp互相调用实例(c/cpp调用java )
- HDU 5072 Coprime (单色三角形问题+容斥原理)
- android Junittest
- Linux 下删除或创建以特殊特殊字符的文件