本帖最后由 love'点点 于 2014-11-7 14:36 编辑
不废话,上代码!
[C#] 纯文本查看 复制代码 /// <summary>
/// 获取当前页面的URL(五个数字可选 1~5 )
/// </summary>
/// <param name="selectNO">1完整url,2域名之后,3域名之后不含参数,4只有域名,5获取参数</param>
/// <returns></returns>
public string getNowURL(int selectNO)
{
string strURL="";
switch (selectNO)
{
case 1:
strURL = HttpContext.Current.Request.Url.ToString();
break;
case 2:
strURL = HttpContext.Current.Request.RawUrl;
break;
case 3:
strURL = HttpContext.Current.Request.Url.AbsolutePath;
break;
case 4:
strURL = HttpContext.Current.Request.Url.Host;
break;
case 5:
strURL = HttpContext.Current.Request.Url.Query;
break;
default:
strURL = HttpContext.Current.Request.Url.ToString();
break;
}
return strURL;
}
项目用到,总结一下!方便你我他!
|