URL properties of Request to ASP.NET
The following attributes are some of the usefull properties of the URL object. I use the following url to send my request to localhost:
And I get the following results:
And the code to do it is as followes:
http://localhost/Test/Asghar.aspx?test=fine
And I get the following results:
AbsolutePath = /Test/Asghar.aspx
AbsoluteUri = http://localhost/Test/Asghar.aspx?test=fine
Authority = localhost
DnsSafeHost = localhost
Fragment =
Host = localhost
HostNameType= Dns
IsAbsoluteUri = True
IsFile = False
LocalPath = /Test/Asghar.aspx
OriginalString = http://localhost:80/Test/Asghar.aspx?test=fine
PathAndQuery = /Test/Asghar.aspx?test=fine
Port = 80
Query = ?test=fine
Scheme = http
UserEscaped = False
UserInfo =
And the code to do it is as followes:
AbsolutePath = <%= System.Web.HttpContext.Current.Request.Url.AbsolutePath %> AbsoluteUri = <%= System.Web.HttpContext.Current.Request.Url.AbsoluteUri %> Authority = <%= System.Web.HttpContext.Current.Request.Url.Authority %> DnsSafeHost = <%= System.Web.HttpContext.Current.Request.Url.DnsSafeHost %> Fragment = <%= System.Web.HttpContext.Current.Request.Url.Fragment %> Host = <%= System.Web.HttpContext.Current.Request.Url.Host %> HostNameType= <%= System.Web.HttpContext.Current.Request.Url.HostNameType.ToString() %> IsAbsoluteUri = <%= System.Web.HttpContext.Current.Request.Url.IsAbsoluteUri %> IsFile = <%= System.Web.HttpContext.Current.Request.Url.IsFile %> LocalPath = <%= System.Web.HttpContext.Current.Request.Url.LocalPath %> OriginalString = <%= System.Web.HttpContext.Current.Request.Url.OriginalString %> PathAndQuery = <%= System.Web.HttpContext.Current.Request.Url.PathAndQuery %> Port = <%= System.Web.HttpContext.Current.Request.Url.Port %> Query = <%= System.Web.HttpContext.Current.Request.Url.Query %> Scheme = <%= System.Web.HttpContext.Current.Request.Url.Scheme %> UserEscaped = <%= System.Web.HttpContext.Current.Request.Url.UserEscaped %> UserInfo = <%= System.Web.HttpContext.Current.Request.Url.UserInfo %>