DotnetZip使用方法見此文章https://www.cnblogs.com/pengze0902/p/6124659.html在netframework環境下,使用上面文章中的設置Encoding為Default的方法即可解決中文亂碼問題 但是當我使用.net6創建控制台項目並採用上述代碼時, ...
asp.net core 6.0網站在其他伺服器上,本地運行都正常,遷移到 部署到windowsserver2019 iis上 ,出現大於50k的圖片無法上傳,後來追蹤日誌發現報以下異常:
ERROR Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery - An exception was thrown while deserializing the token.
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted.
---> System.Security.Cryptography.CryptographicException: The key {5bb7f024-2ca9-48a6-9f35-f7aa16b0a2b9} was not found in the key ring. For more information go to http://aka.ms/dataprotectionwarning
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.GetCookieTokenDoesNotThrow(HttpContext httpContext)
大意是無法在伺服器上驗證防偽令牌。錯誤:"Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException:無法解密防偽令牌
最後搜索解決方案如下
修改IIS應用程式池標識,使其具有讀取密鑰的足夠許可權。更多詳細信息,您可以參考以下步驟:
1.打開IIS管理控制台:
2.選擇您的應用程式池
3.將應用程式池標識修改為本地系統或其他有足夠許可權訪問密鑰的域帳戶。
改成本地賬號,完美解決 特做記錄