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

可以 使用

 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的文件名了

你可能感兴趣的:(Web,String,C#,url)