获取页面文件名以及URL路径

来源:互联网 发布:网络小本创业 编辑:程序博客网 时间:2024/04/25 16:28

可以 使用

 string url=Request.Url.ToString();

来获得。

然后用 C# 的字符处理函数如:

string.indexof()

string.lastindexof()

结合 string.remove

来进行截断。

例如:

string webPage=url.Remove(0,url.Lastindexof("/")+1); //这里获得web页面文件名和其后的get参数字符串

webPage=webPage.Remove(indexof("?"));//这样就得到 webpage的文件名了

原创粉丝点击