[英]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.