How to read Hash Parameters in Url [duplicate] - c#

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to get Url Hash (#) from server side
I have hash parameters in url
Can any body please help me to how to read Hash parameters value from Url using C#?
www.example.com/default.aspx#!type=1
How to read value of type?

The hash part is only used and available on the client. You cannot read it from ASP.NET / C#.

Split the URL at the hash (#).
Then split the second element from above at each ampersand (&)
Then split each of those at the equals (=) sign.
You will then have all the parameters and values.
If this was asking about a ASP.net application, you want to use Request.QueryString["type"] to get the value.

Related

The + character in the parameter is returned as a space [duplicate]

This question already has answers here:
How to encode the plus (+) symbol in a URL
(6 answers)
Closed 1 year ago.
I created the custom link on the asp.net core project. And i tried to getting parameters in the link on the controller.
i need to prmtr1 and prmt2 values but '+' char in the prmtr1 return to ' '(space) value. I must get 'j+vNMbBKUGU=' but im getting 'j vNMbBKUGU='
link: blablabla/contract?prmtr1=j+vNMbBKUGU=&prmtr2=BIIOnHXUgGM=
if i change space char to + char, my problem fixed but i think it's not good idea. I hope you can help me. Thanks.
asp.net assumes that the "+" character is an encoded " " and therefore convert it to a space character.
In javascript you can use the function encodeURIComponent(string) to encode your parameters before sending.
You can read more about the function here: https://www.w3docs.com/snippets/javascript/how-to-encode-javascript-url.html#the-encodeuricomponent-function-5
And you can find more information about why this is happening here: https://stackoverflow.com/a/2678602/16154479

I m looking for a REGEX to split a response with & as part of the value [duplicate]

This question already has answers here:
How to read values from the querystring with ASP.NET Core?
(14 answers)
Closed 3 years ago.
So I get a response as pairs of keys and values
sum=199&name=arik&business=arik & sons&address=xyz
I m looking for a REGEX that will be able to split the keys and values
giving the following guidelines
1. first pair doesn't have the &
2. it could have & inside some of the values
Thank you
The most practical thing to do is use the uri class (even if it's a fake url) and then use HttpUtility.ParseQueryString

Including encrypted key in url [duplicate]

This question already has answers here:
How to achieve Base64 URL safe encoding in C#?
(10 answers)
Closed 4 years ago.
I have an encrypted url that gets passed in as a query string such as
myurl.com/key/cYtLPBlnOUOi+8413hTQLz+GGeoiLeLhbPuNhK+saqhc/f/FgtKSbcInVB9IIoWER71L1Q6vrnLv8o3eKI843|M==
I am having issues, I believe due to the special characters such as the forward slash. How can I accept this url?
Add a reference to System.Web (Project > References > Add reference > System.Web)
System.Web.HttpUtility.UrlEncode(YOUR_STRING);

Get URL Params with '#' [duplicate]

This question already has answers here:
Retrieving anchor link in URL for ASP.NET
(3 answers)
Closed 8 years ago.
I have a url that receive request with parameters set like this from the return URL of the GoogleAuth. :
LoginReturn.aspx#state=/profile&access_token=token&token_type=Bearer&expires_in=3600
Because of '#' (instead of '?'), if I look in Request.QueryString or Request.RawUrl, there is no parameter and I need to get this access_token.
What is the correct way to get those parameters ?
Thanks for your help !
Everything that follows # is only for the browser. It's usually used to navigate to an anchor in a page, or for single page applications.
The correct way is to edit your query from # to ?

Detecting and replacing all smilies in a string [duplicate]

This question already has answers here:
Mysql server does not support 4-byte encoded utf8 characters
(8 answers)
Closed 7 years ago.
I have a integration with facebook and have notice that thay sends for example u+1f600 that is called a grinning face. When I try to store this in the MySQL Text field I get Server does not support 4-byte encoded so a fast solution is to remove all these special chars from the string.
The question is how? I know about the u+1f600 but I suspect that there could be more of them.
Consider switching to MySQL utf8mb4 encoding... https://mathiasbynens.be/notes/mysql-utf8mb4

Categories