Media Library Issue

Francis Carroll asked on August 30, 2023 16:23

Hey

I am running Kentico 13, IIS10 and ASP .NET CORE

I am having issues with a content user today where they tried to add an image to the default kentico rich text widget. It displayed the two errors below and clearing the browser cache resolved this issue.

Does anyone know why this occurs as it was working perfectly fine yesterday?

Event ID:46085
Event type:Error
Event time:8/30/2023 3:12:05 PM
Source:Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery
Event code:TokenDeserializeException
User ID:65
User name:public
Description:An exception was thrown while deserializing the token.
Message: The antiforgery token could not be decrypted.

Exception type: Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException
Stack trace:
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.GetCookieTokenDoesNotThrow(HttpContext httpContext)

Message: The key {Key} was not found in the key ring. For more information go to http://aka.ms/dataprotectionwarning

Exception type: System.Security.Cryptography.CryptographicException
Stack trace:
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)

Event ID:46083
Event type:Error
Event time:8/30/2023 3:11:59 PM
Source:Media files usage
Event code:PROCESS_SEARCH_TASK
Description:Message: Error while processing index MediaFilesUsage: An error occurred while obtaining the index writer. This may be caused by a fatal error or index corruption. Consider rebuilding the index if the problem persists.

Exception type: CMS.Search.SearchIndexException
Stack trace:
at CMS.Search.SearchIndexProvider.GetWriter(Boolean create)
at CMS.Search.SearchHelper.Update(ILuceneSearchDocument iDoc, SearchIndexInfo indexInfo)
at CMS.MediaLibrary.PageSearchDocumentManager.UpdatePage(SearchIndexInfo searchIndex, TreeNode page)
at CMS.MediaLibrary.PageSearchDocumentManager.ExecutePageUpdate(SearchIndexInfo searchIndex, Int32 pageId)
at CMS.MediaLibrary.PageSearchDocumentManager.ProcessUpdateTask(SearchTaskInfo taskInfo, SearchIndexInfo searchIndex)
at CMS.MediaLibrary.MediaFilesUsageSearchIndexer.ExecuteUpdateTask(SearchTaskInfo taskInfo)
at CMS.MediaLibrary.MediaFilesUsageSearchIndexer.ExecuteTask(SearchTaskInfo searchTask)

Message: Access to the path '<Path>\App_Data\CMSModules\SmartSearch\MediaFilesUsage\segments_1zek' is denied.

Exception type: System.UnauthorizedAccessException
Stack trace:
at System.IO.FileSystem.DeleteFile(String fullPath)
at CMS.FileSystemStorage.File.Delete(String path)
at CMS.IO.File.Delete(String path)
at Lucene.Net.Index.IndexFileDeleter.DeleteFile(String fileName)
at Lucene.Net.Index.IndexFileDeleter.DecRef(String fileName)
at Lucene.Net.Index.IndexFileDeleter.DeleteCommits()
at Lucene.Net.Index.IndexFileDeleter..ctor(Directory directory, IndexDeletionPolicy policy, SegmentInfos segmentInfos, StreamWriter infoStream, DocumentsWriter docWriter, HashSet`1 synced)
at Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean create, IndexDeletionPolicy deletionPolicy, Int32 maxFieldLength, IndexingChain indexingChain, IndexCommit commit)
at Lucene.Net.Index.IndexWriter..ctor(Directory d, Analyzer a, Boolean create, MaxFieldLength mfl)
at CMS.Search.Lucene3.LuceneIndexWriter..ctor(Directory directory, Analyzer a, Boolean create)
at CMS.Search.Lucene3.LuceneSearchManager.CreateIndexWriter(String path, ISearchAnalyzer analyzer, Boolean create)
at CMS.Search.SearchManager.CreateIndexWriter(String path, ISearchAnalyzer analyzer, Boolean create)
at CMS.Search.SearchIndexProvider.GetWriter(Boolean create)

Recent Answers


Juraj Ondrus answered on August 31, 2023 08:02

Is the admin app running in a web farm? Is there any load balancer? This sounds like some session management issue. Maybe you could try configuring the same machine key on all your web farm servers to ensure the decryption key is the same:

https://stackoverflow.com/questions/23402210/the-anti-forgery-token-could-not-be-decrypted

https://stackoverflow.com/questions/24591082/the-anti-forgery-token-could-not-be-decrypted-even-in-localhost and there many other threads on this error. And I would also recommend checking the docs here:
https://docs.xperience.io/configuring-xperience/setting-up-web-farms/configuring-web-farm-servers#Configuringwebfarmservers-Storingsessionstateonawebfarm and also the next paragraph on the machine key.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 1, 2023 17:59

Hi Francis,

Are you sure these 2 errors are connected? There were 6 seconds between these error messages, typically if they happened during the same action the difference wouldn't be higher than 1-2 seconds.

By the looks of it, could it also be that the CMS editor had page builder opened for a long time, and then tried to add image and it caused this error because antiforgery token has expired?

0 votesVote for this answer Mark as a Correct answer

mazen Ashraf answered on September 4, 2023 10:09

I had these errors too. And still can't solve it.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.