private IUserContract _UserService; public IUserContract UserService { get { if (_UserService == null) { _UserService = ((IContainerProviderAccessor)HttpContext.Current.ApplicationInstance).ContainerProvider.ApplicationContainer.Resolve<IUserContract>(); } return _UserService; } }
改为
public IUserContract UserService { get { return ((IContainerProviderAccessor)HttpContext.Current.ApplicationInstance).ContainerProvider.RequestLifetime.Resolve<IUserContract>(); } }
时间: 2024-10-16 08:42:12