如標(biāo)題所示,我得到:Base-64 char數(shù)組的長(zhǎng)度無(wú)效。我在這里已經(jīng)閱讀了有關(guān)此問(wèn)題的信息,似乎建議是將ViewState如果較大則存儲(chǔ)在SQL中。我正在使用具有大量數(shù)據(jù)收集功能的向?qū)?,因此我的ViewState很大。但是,在我轉(zhuǎn)向“數(shù)據(jù)庫(kù)存儲(chǔ)”解決方案之前,也許有人可以看看并告訴我是否還有其他選擇?我使用以下方法構(gòu)造要發(fā)送的電子郵件: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);}Encrypt方法如下所示: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);}這是Hotmail中的HTML外觀:請(qǐng)單擊下面的鏈接或?qū)⑵湔迟N到瀏覽器中以驗(yàn)證您的電子郵件帳戶(hù)。http:// localhost:1563 / Accounts / VerifyEmail.aspx?a = YOHY57xYRENEOu3H + FGq1Rf09AZAI56EPjfwuK8XWKg =在接收端,VerifyEmail.aspx.cs頁(yè)面的行如下: 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);可以通過(guò)代碼修復(fù)糾正此錯(cuò)誤,還是必須將ViewState存儲(chǔ)在數(shù)據(jù)庫(kù)中?
Base-64 char數(shù)組的長(zhǎng)度無(wú)效
鴻蒙傳說(shuō)
2019-10-17 14:55:16