Archive for tag: URL

URL fragments or parts and get Paths using HttpRequest in C#

URL fragments or parts and get Paths using HttpRequest, If we want URL fragments or parts of the URL we can get that in C# using HttpRequest as like follwoing:

In following example we have used those properties of .Net Framework Library

Below is just example URL that has taken for us to understand:

as below

HttpRequest path and URL fragments / parts

Request.ApplicationPath: /Products

Request.CurrentExecutionFilePath: /Products/Product-name/Detail.aspx

Request.FilePath: /Products/Product-name/Detail.aspx

Request.Path: /Products/Product-name/Detail.aspx/path/info

Request.PathInfo: /path/info

Request.PhysicalApplicationPath: D:\Inetpub\wwwroot\CambiaWeb\Products\

Request.RawUrl: /Products/Product-name/Detail.aspx/path/info?q=item

Request.Url.AbsolutePath: /Products/Product-name/Detail.aspx/path/info




Request.Url.LocalPath: /Products/Product-name/Detail.aspx/path/info

Request.Url.PathAndQuery: /Products/Product-name/Detail.aspx/path/info?q=item

Request.Url.Port: 80

Request.Url.Query: ?q=item

Request.Url.Scheme: http

Request.Url.Segments: /

Those are all the ways to get full, partial, fragments or parts of the URL.

THank you very much for going through this article.

Get and set #hash value in URL using Javascript or jQuery

Get or set #hash value in URL using Javascript or jQuery, we can change URL without refreshing page using Javascript or jQuery by changing #hash value, like below:


Javascript or jQuery

// get #hash value
var hashValue = window.location.hash

// set #hash value, it will change URL to
window.location.hash = "example-page"

If you have question don't forget to ask.

Thank you for going through