从网址中删除内容 [英] remove the content from url
本文介绍了从网址中删除内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网址是www.w3schools.com/Asp/sample .aspx我想删除该网址中的文件夹即/ Asp以访问另一个页面如何做到这一点
解决方案
以下是获取新内容的方法当前网址: -
Ex
string all = www.w3schools.com/Asp/sample.aspx 跨度>;
string part = all.Substring( 0 ,all.LastIndexOf(' /'));
string part1 = part.Substring( 0 ,part.LastIndexOf(' /'));
string part2 = all.Substring(all.LastIndexOf(' /'),all.Length-part.Length);
string newURL = part1 + part2;
如果你想要动态获取当前的URL然后你可以在这篇文章中提到: -
http://forums.asp.net/t/1422355.aspx?Get+current+URL+in+ASP+NET [ ^
Hi,
My url is "www.w3schools.com/Asp/sample.aspx" i want to remove folder in that url i.e "/Asp" to access another page how to do that
解决方案
Here is the way you can get the new URL from current one :-
Ex
string all = "www.w3schools.com/Asp/sample.aspx"; string part = all.Substring(0, all.LastIndexOf('/')); string part1 = part.Substring(0, part.LastIndexOf('/')); string part2 = all.Substring(all.LastIndexOf('/'), all.Length-part.Length); string newURL = part1 + part2;
If you want to get the current URL dynamically then you can get like mentioned here in this post :-
http://forums.asp.net/t/1422355.aspx?Get+current+URL+in+ASP+NET[^]
这篇关于从网址中删除内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文