只需要在Global.asax.cs 的加上Application_BeginRequest
  protected void Application_BeginRequest(Object sender, EventArgs e)
  {
   string oldUrl = HttpContext.Current.Request.RawUrl ;
   string pattern = @"^(.+)default/(\d+)\.shtml(\?.*)*$";
   string replace = "$1default.aspx?id=$2";
   if(Regex.IsMatch(oldUrl, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
   {
    string newUrl = Regex.Replace(oldUrl, pattern, replace, RegexOptions.Compiled | RegexOptions.IgnoreCase);
    this.Context.RewritePath(newUrl);
   }
  }
 
然后在IIS中修改Shtml的映射
c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
去掉检查文件是否存在的选择
 
实现:
default.aspx?id=123
重写为
default/123.shtml
http://blog.csdn.net/dengenming/archive/2007/03/21/1535808.aspx
posted on 2007-06-05 00:39  mbskys  阅读(166)  评论(0)    收藏  举报