Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

Get URL path information in web application

Modified: 2009/10/20 12:11 by jim - Categorized as: ASP.NET
string http;
if (Request.IsSecureConnection)
{
    http = "https://";
}
else
{
    http = "http://";
}

string hostName = Request.Url.Host;
int port = ":" + Request.Url.Port;

string appPath = Request.ApplicationPath;
// where is my aspx page:
string path = http + hostname + port + "/" + appPath;

http, hostname and port can also be retrieved with
Request.Url.GetLeftPart(UriPartial.Authority)

 © Evident Interactive BV