Reputation: 6540
I have the following path:
-http://localhost/portal/reportview.aspx
but I need to retrieve the first 3 parts:
-http://localhost/portal/
Ive tried HttpContext.Current.Request.Url.GetLeftPart();
with no luck.
Upvotes: 0
Views: 1302
Reputation: 33839
Try this;
string s = "http://localhost/portal/reportview.aspx";
string y = string.Format("{0}//{2}/{3}/",s.Split('/'));
Upvotes: 1
Reputation: 148180
You can use substring.
string str = "http://localhost/portal/reportview.aspx";
string left = str.Substring(0, str.LastIndexOf("/"));
Upvotes: 1