HttpContext.Current.RewritePath方法重写URL

if (!IsPostBack)
 {
                //如果请求ID为空,则重写URL为:~/index.aspx?ID=shouji.115sou.com
                if (Request.QueryString["ID"]==null || Request.QueryString["ID"].Trim()=="")
                {
                    HttpContext.Current.RewritePath("~/index.aspx?ID=shouji.115sou.com");
                }

                Response.Write(Request.QueryString["ID"]);
 }

  

 NameDescription
Public method RewritePath(String) 重写URL的路径
Public method RewritePath(String, Boolean) 重写URL路径和一个布尔值,指定是否服务器资源虚拟路径的修改
Public method RewritePath(String, String, String) 重写URL通过使用给定的路径路径信息和查询字符串信息
Public method RewritePath(String, String, String, Boolean) 重写URL使用给定的虚拟路径路径信息查询字符串信息一个布尔值,指定是否客户端文件路径设置为重写路径
原文地址:https://www.cnblogs.com/webapi/p/4353007.html