做法如下:打开global.asax.cs,定位到protected void Application_BeginRequest(Object sender, EventArgs e)。从方法名我想也能猜到它是做什么的。输入如下代码: 
复制代码代码如下:

protected void Application_BeginRequest(Object sender, EventArgs e) 

string oldUrl = HttpContext.Current.Request.RawUrl ; 
string pattern = @"^(.+)default/(\d+)\.aspx(\?.*)*$"; 
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); 



有了上边这段代码,我访问一个类似:.../default/123.aspx 的网址,当然这个网址在我的电脑上不存在,它就会被定向到:.../default.aspx?id=123。