正如標題無效長度說,我得到:對於BASE-64字符數組
無效長度爲一個基地-64炭 陣列。
我已閱讀關於這個問題在這裏,似乎 建議是存儲ViewState在SQL中,如果它很大。我是 使用了一個具有大量數據收集的嚮導,因此我的ViewState的機會很大 很大。但是,在我轉向「店內數據庫」 解決方案之前,也許有人可以看看並告訴我我是否有其他選項 ?
public void SendEmailAddressVerificationEmail(string userName, string to)
{
string msg = "Please click on the link below or paste it into a browser to verify your email account.<BR><BR>" +
"<a href=\"" + _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +
userName.Encrypt("verify") + "\">" +
_configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +
userName.Encrypt("verify") + "</a>";
SendEmail(to, "", "", "Account created! Email verification required.", msg);
}
的加密方法是這樣的:
public static string Encrypt(string clearText, string Password)
{
byte[] clearBytes = System.Text.Encoding.Unicode.GetBytes(clearText);
PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
byte[] encryptedData = Encrypt(clearBytes, pdb.GetBytes(32), pdb.GetBytes(16));
return Convert.ToBase64String(encryptedData);
}
下面是HTML的樣子Hotmail中:
我使用下面的方法構建的電子郵件交付
請點擊下面的鏈接或 將其粘貼到瀏覽器以驗證您的 電子郵件帳戶。
http://localhost:1563/Accounts/VerifyEmail.aspx?a=YOHY57xYRENEOu3H+FGq1Rf09AZAI56EPjfwuK8XWKg=
在接收端,VerifyEmail.aspx.cs頁面有一行:
string username = Cryptography.Decrypt(_webContext.UserNameToVerify, "verify");
這裏是UserNameToVerify吸氣:
public string UserNameToVerify
{
get
{
return GetQueryStringValue("a").ToString();
}
}
這裏是GetQueryStringValue方法:
private static string GetQueryStringValue(string key)
{
return HttpContext.Current.Request.QueryString.Get(key);
}
和解密方法是這樣的:
public static string Decrypt(string cipherText, string password)
{
**// THE ERROR IS THROWN HERE!!**
byte[] cipherBytes = Convert.FromBase64String(cipherText);
可這個錯誤可以用一個代碼修復補救或我必須存儲ViewState的數據庫?
PLZ發送我TEH誤差 – DevDemon 2010-05-27 23:37:36
DevDemon - 作爲張貼的誤差「出現FormatException:用於基本-64字符數組長度無效」。還有什麼我應該送? – 2010-05-27 23:55:04