Return to Snippet

Revision: 35038
at November 1, 2010 12:40 by housecor


Updated Code
Uri address = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);
			if (address.Segments[0] == "Admin") //do something...

string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx

string host = HttpContext.Current.Request.Url.Host;
// localhost

Revision: 35037
at November 1, 2010 12:39 by housecor


Updated Code
Uri address = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);
			if (address.Segments[0] == "Admin") //do something...

Revision: 35036
at November 1, 2010 12:39 by housecor


Initial Code
Uri address = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);
			if (address.Segments[0] == "Admin")

Initial URL

                                

Initial Description
Segments is a zero based array that starts with the first segment.

Initial Title
Get Current URL and Segments. Also, get host or path.

Initial Tags

                                

Initial Language
C#