[英]XSRF token expired after website publish to IIS
我正在使用ASP.NET Boilerplate框架,在每個頁面中都放置了以下代碼。
@inject IAbpAntiForgeryManager AbpAntiForgeryManager
@{
AbpAntiForgeryManager.SetCookie(Context);
}
我將應用程序服務稱為:
var xhr = abp.services.app.order.add(data);
xhr.done(function (data) {
alert(data);
});
當我在localhost中運行時,一切正常,即使重建項目,XSRF令牌也不會過期。 每次單擊[將網站發布到IIS]時,所有的ajax請求都將返回400 Bad Request,我猜這是因為XSRF令牌已過期,在瀏覽器中單擊F5之后,一切恢復了正常。 這對用戶來說太煩人了,我能做些什么來防止此錯誤? 還是自動刷新令牌?
謝謝!
LOG文件中的錯誤消息:
ERROR 2019-02-12 13:40:09,773 [71 ] .Antiforgery.Internal.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 {996d31d2-0fa3-4ffe-8e82-e155c1486d33} was not found in the key ring.
根據錯誤,聽起來您的數據保護密鑰在發布時已經旋轉。 在此處查看有關數據保護的文檔: https : //docs.microsoft.com/zh-cn/aspnet/core/security/data-protection/introduction?view=aspnetcore-2.2 。 有很多選項如何配置它,在哪里存儲密鑰等。您將需要更改它存儲它們的方式。
有關配置數據保護的更多信息: https : //docs.microsoft.com/zh-cn/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-2.2 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.