Url重写

protected void Application_BeginRequest(object sender, EventArgs e)
        {
            #region 重写显示章节列表路径
            //http://localhost:19826/Course/CourseController.ashx?action=chapter&courseid=2
            Match match = Regex.Match(Context.Request.Url.ToString(), @"/Course/CourseController_(chapter)(d+).ashx");
            if (match.Success)
            {
                string chapter = match.Groups[1].Value;
                string courseid = match.Groups[2].Value;
                Context.RewritePath("/Course/CourseController.ashx?action=" + chapter + "&courseid=" + courseid);
            } 
            #endregion

        }
原文地址:https://www.cnblogs.com/adolphyang/p/4844625.html