开发者

HttpServerUtility.UrlTokenDecode only seems to return null

开发者 https://www.devze.com 2023-03-16 11:15 出处:网络
I seem to be having an issue with the HttpServerUtility.UrlTokenDecode(string), as it is constantly returning null, causing the program to crash.

I seem to be having an issue with the HttpServerUtility.UrlTokenDecode(string), as it is constantly returning null, causing the program to crash.

From what I have gathered, this method will convert a string to it's base64 Byte-Array. Unfortunately, the original developer of the code is no longer with us, and it seems not many people in my office are familiar with the code.

public string DecodeUrlData(string urlData)
{
    string lsReturnVal = string.Empty;
    byte[] decodedrtfBytes = HttpServerUtility.UrlTokenDecode(urlData);

    lsReturnVal = System.Text.ASCIIEncoding.ASCII.GetString(decodedrtfBytes);
    return lsReturnVal;
}

That is the code that has been written, and urlData has the f开发者_Python百科ollowing value:

urlData = "pdfSignature template testing."

(It should also be known that urlData may have either a "string" value, or a rtfformatted string)

But what ends up happening is when the HttpServerUtility.UrlTokenDecode(urlData) line is executed, the byte array ends up being null (causing an exception in the following line).

Is there another way to convert the string to base64 that would work, or why does it keep producing a null value?


According to the HttpServerUtility.UrlTokenDecode documentation, the input parameter should be a Url token previously encoded via UrlTokenEncode.

Quote:

The UrlTokenDecode method converts a URL string token, which encodes binary data as base 64 digits, to its equivalent byte array representation. Use the UrlTokenDecode method to decode tokens transmitted on the URL and encoded by using the UrlTokenEncode.

0

精彩评论

暂无评论...
验证码 换一张
取 消