62,041
社区成员
发帖
与我相关
我的任务
分享
void Application_BeginRequest(object sender, EventArgs e)
{
string output = Regex.Replace(Context.Request.Path, @"(\w+).aspx", "n$1");
if (!string.IsNullOrEmpty(output))
{
Context.RewritePath(output);
}
}
这样,abcp.aspx?id=22233&title=abcd来访,显示的是nabcp.aspx?id=22233&title=abcd
string input = "p.aspx?id=22AAAAAAp.aspx?id=22233&title=abcd p.aspx/22 p.aspx/22/";
MatchCollection mCollection = Regex.Matches(input, @"(p.aspx\?id=\d+(&title=[^p]+)?)|(p.aspx/\d+/?)");
效果
\w+\.aspx(\?\w+=\w+(&\w+=\w+)*|/(\w+/?)+)$