Wednesday, October 7, 2020

XP and XC 9.3 - Fix for antiforgery error while user registration and login


During a new CD server machine setup, I found this issue during the login and registration, the error is very straight forward and self-explanatory that it's related to security/ or access of the token beetwen sites.

Error Details
 27432 22:33:04 ERROR One or more exceptions occurred while processing the subscribers to the 'sessionEnd:batch:starting' event.  
 Exception[1]: Sitecore.XConnect.XdbCollectionUnavailableException   
 Message[1]: An error occurred while sending the request.   
 Source[1]: Sitecore.Xdb.Common.Web   
   at Sitecore.Xdb.Common.Web.Synchronous.SynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory)  
   at Sitecore.XConnect.Client.XConnectSynchronousExtensions.SuspendContextLock(Func`1 taskFactory)  
   at Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.Initialize(XmlNode configNode)  
   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)  
   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert)  
   at Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert)  
   at Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient(String clientConfigPath)  
   at Sitecore.Analytics.XConnect.DataAccess.BatchEnabledXdbRuntimeContext..ctor(IXdbContextFactory factory)  
   at Sitecore.Analytics.Events.BatchEventHandler.OnBatchStarting(Object sender, EventArgs args)  
   at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters, EventResult result)   
 27432 22:33:04 ERROR Cannot execute 'sessionEnd:batch:starting' event  
 Exception: System.AggregateException  
 Message: One or more exceptions occurred while processing the subscribers to the 'sessionEnd:batch:starting' event.  
 Source: Sitecore.Kernel  
   at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters, EventResult result)  
   at Sitecore.Events.Event.RaiseEvent(String eventName, Object[] parameters)  
   at Sitecore.Kernel.Web.SessionExpirationProcessor.TryRaiseEvent(String eventName, Object[] parameters)  
 Nested Exception  
 Exception: Sitecore.XConnect.XdbCollectionUnavailableException  
 Message: An error occurred while sending the request.  
 Source: Sitecore.Xdb.Common.Web  
   at Sitecore.Xdb.Common.Web.Synchronous.SynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory)  
   at Sitecore.XConnect.Client.XConnectSynchronousExtensions.SuspendContextLock(Func`1 taskFactory)  
   at Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.Initialize(XmlNode configNode)  
   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)  
   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert)  
   at Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert)  
   at Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient(String clientConfigPath)  
   at Sitecore.Analytics.XConnect.DataAccess.BatchEnabledXdbRuntimeContext..ctor(IXdbContextFactory factory)  
   at Sitecore.Analytics.Events.BatchEventHandler.OnBatchStarting(Object sender, EventArgs args)  
   at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters, EventResult result)  
 Nested Exception  
 Exception: System.Net.Http.HttpRequestException  
 Message: An error occurred while sending the request.  
 Source: mscorlib  
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()  

here is a good read about the anti

https://www.c-sharpcorner.com/article/understand-antiforgeri-token-in-asp-net-mvc/#:~:text=Anti-forgery%20stands%20for%20%E2%80%9CAct%20of%20copying%20or%20imitating,trusted%20source%20sending%20the%20data%20to%20the%20site.

https://www.devcurry.com/2013/01/what-is-antiforgerytoken-and-why-do-i.html

Solution -  I opened the mmc.exe, selected the certificates and allowed all application pools access to the CD server certificate.



No comments:

Post a Comment