On my asp.net mvc page, I create a link that displays as follows:
http://localhost:3035/Formula/OverView?colorId=349405&paintCode=744&name=BRILLANT%20SILVER&formulaId=570230
According to the W3C validator, this is incorrect, and these are errors after the first ampersand. It complains about encoding and is not encoded, and the entity & is not recognized, etc.
AFAIK and should not be encoded, because it is a separator for a pair of key values.
For those who are interested: I send these parades as querystring, and not as "/" divided values, because there is no decent way to pass additional parameters that I know of.
To join all the bits:
- The href attribute for binding (<a>) needs an encoded value
- & encodes &
- to encode '&' when it is part of your parameter value, use% 26
Will not encode the ampersand and make it part of my parameter value? I need to separate the second variable from the first
Really, coding my href value, I get rid of errors. Now I'm wondering what to do if, for example, my colorId is "123 & 456", where the ampersand is part of the value. Since the delimiter must be encoded, what to do with encoded ampersands. Do they need to be encoded twice like this?
So, to get the URL:
www.mySite.com/search?query=123&456&page=1
What should be the value of href?
Also, I think I'm the first person in the world to take care of this. go check www and count the pages that get their query string checked in the W3C validator ..