Security - The ASP.NET XAF application throws ObjectDisposedException when the IsGranted method is called
Call stack:
in DevExpress.Xpo.Session.Connect()
in DevExpress.Xpo.Session.get_ObjectLayer()
in DevExpress.ExpressApp.Security.Xpo.Adapters.SessionHelper.GetRealSession(Session session)
in DevExpress.ExpressApp.Security.Xpo.Adapters.SessionHelper.GetRealSession(Session session)
in DevExpress.ExpressApp.Security.Xpo.Adapters.XPOSecurityAdapterProviderBase.GetUnitOfWork(IObjectSpace objectSpace)
in DevExpress.ExpressApp.Security.AdapterFacade.GetUnitOfWork(IObjectSpace objectSpace)
in DevExpress.ExpressApp.Security.SelectDataSecurityCache.TryGetValue(IObjectSpace objectSpace, ISelectDataSecurity& selectDataSecurity)
in DevExpress.ExpressApp.Security.SecurityStrategy.NeedToUpdateSelectDataSecurity(IObjectSpace objectSpace)
in DevExpress.ExpressApp.Security.SecurityStrategy.CreateSelectDataSecurity(IObjectSpace objectSpace)
in DevExpress.ExpressApp.Security.SecurityStrategy.IsGranted(IPermissionRequest permissionRequest)
in DevExpress.ExpressApp.SecuritySystem.IsGranted(IPermissionRequest permissionRequest)
in DevExpress.ExpressApp.DataManipulationRight.HasPermissionTo(Type objectType, String memberName, Object targetObject, IObjectSpace objectSpace, String operation)
in DevExpress.ExpressApp.DataManipulationRight.CanDelete(Type type, Object targetObject, CollectionSourceBase collectionSourceBase, IObjectSpace objectSpace)
in DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController.UpdateActionState()
in DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController.DoUpdateActionState()
in DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController.ObjectSpace_ModifiedChanged(Object sender, EventArgs e)
in System.EventHandler.Invoke(Object sender, EventArgs e)
in DevExpress.ExpressApp.BaseObjectSpace.OnModifiedChanged()
in DevExpress.ExpressApp.Xpo.XPObjectSpace.SetModified(Object obj, ObjectChangedEventArgs args)
in DevExpress.ExpressApp.BaseObjectSpace.SetModified(Object obj)
in DevExpress.ExpressApp.Web.SystemModule.WebModificationsController.SetObjectSpaceModified()
in DevExpress.ExpressApp.Web.SystemModule.WebModificationsController.Save(SimpleActionExecuteEventArgs args)
in DevExpress.ExpressApp.SystemModule.ModificationsController.saveAction_OnExecute(Object sender, SimpleActionExecuteEventArgs e)
in DevExpress.ExpressApp.Actions.SimpleAction.RaiseExecute(ActionBaseEventArgs eventArgs)
in DevExpress.ExpressApp.Actions.ActionBase.ExecuteCore(Delegate handler, ActionBaseEventArgs eventArgs)
InnerException is null
As a workaround, you can use either of these solutions:
1.Disable the Security Permissions Caching.
To do this, remove the "security.RegisterXPOAdapterProviders();" code from your Global.asax.cs file. This code is placed in the Application_Start method by default.
2.Add the descendant of the SecurityStrategyComplex class and override the ReloadPermissionsCore method:
C#using DevExpress.ExpressApp.Security;
namespace YourApplicationName.Web {
public class CustomSecurityStrategyComplex : SecurityStrategyComplex {
protected override void ReloadPermissionsCore() {
if(User != null && LogonObjectSpace != null) {
LogonObjectSpace.ReloadObject(User);
}
}
}
}
Rebuild your solution. In the Application Designer, add the CustomSecurityStrategyComplex item from the Toolbox.