I have such URL
localhost/Login/LogOn?ReturnUrl=/#&q=my%20search%20word&f=1//447044365|2//4
I need to get hash parameters to navigate in the application after authentication.
I try to catch it like this
<input name="returnUrl" value="<%= ViewContext.HttpContext.Request.Url.PathAndQuery %>" type="hidden" />
But result is
/Login/LogOn?ReturnUrl=/
I tried to take away "/#" in the URL, then I get whole URL. But I need to use this URL as it is.
Why was URL cutted?
The hash of a url can be found by creating a new URL Javascript object from the URL string, and then using its hash property to get the value of the hash fragment. Note that this will include the # character also. If the url does not contains a hash, then an empty string "" will be returned.
Answer: Use the Window. location Property You can simply use the location property of a window (i.e. window. location ) to check whether a URL contain hash ( # ) or fragment component or not in JavaScript.
In a URL, a hash mark, number sign, or pound sign ( # ) points a browser to a specific spot in a page or website. It is used to separate the URI of an object from a fragment identifier. When you use a URL with a # , it doesn't always go to the correct part of the page or website.
The browser does not send the hash fragment to the server. It used on the client-side only. If you need it you will have to access it through client-side script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With