Extract URL Information

To get information about the currently requested URL in ASP.NET use the Request.Url class. For example to extract the information from the URL http://www.example.com/myApp/myPage.aspx?myQs=14 the Request.Url class provides the following properties:

Request.Url = "http://www.example.com/myApp/myPage.aspx?myQs=14"
Request.Url.AbsolutePath: "/myApp/myPage.aspx"
Request.Url.AbsoluteUri: "http://www.example.com/myApp/myPage.aspx?myQs=14"
Request.Url.Authority: "www.example.com"
Request.Url.DnsSafeHost: "www.example.com"
Request.Url.Fragment: ""
Request.Url.Host: "www.example.com"
Request.Url.HostNameType: Dns
Request.Url.IsAbsoluteUri: true
Request.Url.IsDefaultPort: true
Request.Url.IsFile: false
Request.Url.IsLoopback: true
Request.Url.IsUnc: false
Request.Url.LocalPath: "/myApp/myPage.aspx"
Request.Url.OriginalString: "http://www.example.com:80/myApp/myPage.aspx?myQs=14"
Request.Url.PathAndQuery: "/myApp/myPage.aspx?myQs=14"
Request.Url.Port: 80
Request.Url.Query: "?myQs=14"
Request.Url.Scheme: "http"
Request.Url.Segments: {string[3]}
Request.Url.UserEscaped: false
Request.Url.UserInfo: ""

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A WordPress.com Website.

Up ↑

%d bloggers like this: