62,046
社区成员
发帖
与我相关
我的任务
分享
//设当前URL为http://www.a.com/aaaa/bbbbb/ccccc/testweb/default.aspx?id=1
string str=Request.CurrentExecutionFilePath; //获得/aaaa/bbbbb/ccccc/testweb/default.aspx
string[] arr=str.split('/'); //获得数组
string filepath=string.Empty;
if(arr.length>=2)
{
filepath=arr[arr.length-2]+"/"+arr[arr.length-1]; //获得testweb/default.aspx
}
else
{
filepath="/"+arr[0];
}