AutofacConfig.ServiceLocator.BeginLifetimeScope()空异常

时间:2019-01-31 10:23:36

标签: c# sitecore autofac

无论何时调用以下方法,AutofacConfig.ServiceLocator.BeginLifetimeScope()都会设置一个空异常:

private Item GetRedirectedItem()
        {
            using (var scope = AutofacConfig.ServiceLocator.BeginLifetimeScope())
            {
                var userContext = scope.Resolve<IUserContext>();
                var homePageId = userContext?.DefaultSpecialtyHome;
                if (!homePageId.HasValue) return null;
                return Sitecore.Context.Database.GetItem(new ID(homePageId.Value));
            }
        }

不知道我在做什么错。请咨询。

0 个答案:

没有答案
相关问题