如何从URL中迭代根地址? [英] How to iterate root address from a url ?
本文介绍了如何从URL中迭代根地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从完整的URL地址迭代地址的特定部分
我的完整地址是:http://227.172.222.228/BEOSYSTEM/Modules / C / MonthlyActivity
我只想要这个部分http://227.172.222.228/BEOSYSTEM
如何只得到这个部分来自完整网址??
我尝试过:
使用Server.Mappath( 〜);这不起作用
请有人帮帮我??
I want to iterate a specific part of address from the full url address
My full address is : " http://227.172.222.228/BEOSYSTEM/Modules/C/MonthlyActivity "
I want only this part " http://227.172.222.228/BEOSYSTEM"
How to get only this part from full url ??
What I have tried:
Server.MapPath("~"); this is not working
Please somebody help me ??
推荐答案
发布解决方案来关闭这篇文章,因为它在评论中得到解决
Posting as solution to close this post, since it got resolved in Comments
string url = " http://227.172.222.228/BEOSYSTEM/Modules/C/MonthlyActivity";
string target = "BEOSYSTEM";
string result = url.Substring(0,url.IndexOf(target) + target.Length); // http://227.172.222.228/BEOSYSTEM
这篇关于如何从URL中迭代根地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文