[英]how to manipulate the URL path in c# asp.net?
I have the following path: 我有以下路径:
-http://localhost/portal/reportview.aspx
-http://localhost/portal/reportview.aspx
but I need to retrieve the first 3 parts: 但我需要检索前3个部分:
-http://localhost/portal/
-http://本地主机/门户/
Ive tried HttpContext.Current.Request.Url.GetLeftPart();
我已经尝试过
HttpContext.Current.Request.Url.GetLeftPart();
with no luck. 没有运气。
You can use substring. 您可以使用子字符串。
string str = "http://localhost/portal/reportview.aspx";
string left = str.Substring(0, str.LastIndexOf("/"));
Try this; 尝试这个;
string s = "http://localhost/portal/reportview.aspx";
string y = string.Format("{0}//{2}/{3}/",s.Split('/'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.