|zyciis| 我的一段URL改写大家看看能不能怎么改更新效一点,谢谢
--------------------编程问答-------------------- up --------------------编程问答-------------------- 友情帮顶 --------------------编程问答--------------------
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.Request.RawUrl.IndexOf(".xhtml") != -1)
{
string RawUrl = HttpContext.Current.Request.RawUrl.Replace(".xhtml", ".aspx");//将shtml转为aspx
Boolean isMatch = false;
#region 判断网页是否存在,如果存在不进行跳转
try
{
String tempURL = RawUrl;
if (tempURL.LastIndexOf("?") != -1)
{
tempURL = tempURL.Substring(0, tempURL.Length - (tempURL.Length - tempURL.LastIndexOf("?")));
}
if (System.IO.File.Exists(Server.MapPath(tempURL)))
{
isMatch = true;
}
}
catch { }
#endregion
#region 改写商品详细
if (isMatch == false)
{
Regex reg = new Regex(@"([^/]*)(.aspx)", RegexOptions.IgnoreCase);
Match m = reg.Match(RawUrl);
if (m.Success)
{
RawUrl = (Request.ApplicationPath + "/").Replace("//", "/") + "ProductView.aspx?MaterialCode=" + m.Groups[1].Value;
isMatch = true;
}
}
#endregion
Context.RewritePath(RawUrl);
}
}
我也是,关注,希望有高手帮楼主解决! --------------------编程问答-------------------- HttpHandler做这个更简单一些的吧 --------------------编程问答-------------------- 进来了,就学习一下. --------------------编程问答-------------------- 进来了,就学习一下.
上面这话能叫灌水吗?竟然不能发言...... --------------------编程问答-------------------- 楼主实现url重写?
也只能友情帮顶了! --------------------编程问答-------------------- 我只是感觉这里要先判断当前的文件存在不存在比较麻烦了一点
谢谢
补充:.NET技术 , ASP.NET