我在解码带有参数的 Base64 编码 URL 时遇到了这个困难
eg: http://www.example.com/Movements.aspx?fno=hello&vol=Bits & Pieces
我的预期结果应该是:fno = hello vol = Bits & Pieces
#Encoding:
//JAVASCRIPT
var base64 = $.base64.encode("&fno=hello&vol=Bits & Pieces");
window.location.replace("Movements.aspx?" + base64);
#Decoding c#
string decodedUrl = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(Request.Url.Query.Replace("?", ""))); // Replace is used to remove the ? part from the query string.
string fileno = HttpUtility.ParseQueryString(decodedUrl).Get("fno");
string vol = HttpUtility.ParseQueryString(decodedUrl).Get("vol");
实际结果:fno = hello vol = Bits
我搜索了stackoverlow,似乎我需要添加一个自定义算法来解析解码的字符串。但由于实际的 URL 比这个例子中显示的更复杂,我最好向专家寻求替代解决方案!
感谢阅读!