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