I created several virtual directors and I want to be able to get the url from the current http request.
For example:
http://www.site.com/app_1/default.aspx ===> http://www.site.com/app_1/
http://www.site.com/app_2/default.aspx ===> http://www.site.com/app_2/
....
http://www.site.com/app_n/default.aspx ===> http://www.site.com/app_n/
My code:
string urlApp = HttpContext.Current.Request.Url.AbsoluteUri.ToString();
urlApp = urlApp.Substring(0, urlApp.LastIndexOf('/') + 1);
and I tried
string urlApp = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/";
In localhost works great: http://localhost:2468/test.aspx
result http://localhost:2468/
, but when access via virtual directory http://myhost/app_1/test.aspx
result http://myhost/
how can i get http://myhost/app_1/
?