I am working on a razor view which includes a hidden field called Model.Token
. The Token
contains special characters that are then appended to a link in the href attribute.
<a href='http://<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="34585b5755585c5b47401a575b590b405b5f515a0974795b5051581a605b5f515a">[email protected]</a>'>Link</a>
However, I have noticed that if the Token
contains a +
, it is rendered as a blank space in the link. For example:
Model.Token = 'ABC+DE'
Results in the link becoming:
http://localhost.com?token=ABC DE
My question is, how can I encode the Token
in the link so that the +
symbol is not removed? Should I use JavaScript and the encodeURI
function, or is there a more efficient way to achieve this?