I am migrating from .net framework to .net core. In my current application I have:
private static string ToBase64Url(string value) => ToBase64Url(Encoding.UTF8.GetBytes(value));
private static string ToBase64Url(byte[] value)
{
var s = HttpServerUtility.UrlTokenEncode(value).ToCharArray();
return new string(s, 0, s.Length - 1);
}
I tried changing that to:
private static string ToBase64Url(byte[] value)
{
var s = HttpUtility.UrlEncode(value).ToCharArray();
return new string(s, 0, s.Length - 1);
}
However that gives me different results:
test data:
var text = {"alg":"RS256","typ":"JWT"};
result in .net framework: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9
result in .net core: %7b%22alg%22%3a%22RS256%22%2c%22typ%22%3a%22JWT%22%7
what should be the right equivalent here?